Skip to content
Merged

V1 #12

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
fb16d62
Prepare for release 0.4.0-alpha01
jbarr21 Oct 4, 2022
83d39bf
Prepare next development version
jbarr21 Oct 11, 2022
cace4bd
Add Java KSP sample lib
jbarr21 Oct 11, 2022
a453155
Run spotless
jbarr21 Oct 12, 2022
1a2e7af
Exclude failing sample project
jbarr21 Oct 12, 2022
4dec441
Update to Kotlin 1.7.20 & KSP 1.0.8
jbarr21 Nov 14, 2022
7156599
Fix KSP sample lib
jbarr21 Nov 19, 2022
b0f116b
Remove error rethrower
jbarr21 Nov 29, 2022
e22bf2d
XProcessing to v2.5.0 & KotlinPoet to v1.12.0
jbarr21 Jan 31, 2023
87a7124
Revert "XProcessing to v2.5.0 & KotlinPoet to v1.12.0"
jbarr21 Feb 1, 2023
03ab638
Bump KotlinPoet & JavaPoet
jbarr21 Feb 1, 2023
51737d9
Run spotless
jbarr21 Feb 1, 2023
bd9f898
Prepare for release 0.4.0-alpha02
jbarr21 Feb 1, 2023
7afe009
Prepare next development version
jbarr21 Feb 1, 2023
3c41152
Bump XProcessing, Kotlin, & kotlinx-metadata-jvm
jbarr21 Jul 21, 2023
00c141b
Prepare for release 0.4.0-alpha03
jbarr21 Jul 21, 2023
8e4e5f0
Prepare next development version
jbarr21 Jul 21, 2023
31049d7
Prepare for release 0.4.0-alpha04
jbarr21 Jul 21, 2023
7c88008
Fix Room version for sample
jbarr21 Jul 24, 2023
60e9476
Update Dagger version
jbarr21 Jul 24, 2023
c2ea4d2
Update CHANGELOG
jbarr21 Jul 24, 2023
f3de1ab
Set JVM version to 1.8
jbarr21 Sep 19, 2023
4c9b1af
Prepare for release 0.4.0-alpha05
jbarr21 Sep 20, 2023
184f671
Prepare next development version
jbarr21 Sep 20, 2023
97f1bf7
support intellij 2023.2 (232)
davissuber Oct 5, 2023
2019b65
prefer LightJavaCodeInsightFixtureTestCase
davissuber Oct 5, 2023
8a7a2df
update HierarchyBrowserBase children
davissuber Oct 5, 2023
65ef280
stop using project component
davissuber Oct 5, 2023
d72c9be
fix test harness
davissuber Oct 5, 2023
111b7d3
remove "project" keyword from class
davissuber Oct 12, 2023
dfbe856
fix various stuff found during plugin test
davissuber Oct 12, 2023
c3e6f51
remove rule that skips test
davissuber Oct 17, 2023
8327d8b
clean up build script
davissuber Oct 21, 2023
dc43c4a
bump gradle version to match
davissuber Oct 20, 2023
93c4d87
avoid apply plugin
davissuber Oct 21, 2023
ab27a1d
pass in resolved type info
davissuber Oct 27, 2023
6a7863d
remove unused kapt plugin directive
davissuber Nov 3, 2023
dfb9036
check for explicit dependencies
davissuber Nov 2, 2023
c39a4ab
update dokka to support new kotlin
davissuber Mar 6, 2024
e3edd84
Clean various compile warnings
davissuber Dec 14, 2023
b57ab9b
unify tests/samples structure
davissuber Mar 22, 2024
3d4dc3d
Migrate off deprecated case conversion methods
jbarr21 Feb 11, 2025
39a75a6
Centralize source compat java version
jbarr21 Feb 11, 2025
4955c2f
Add Kotlinpoet optin
jbarr21 Feb 11, 2025
e4eba10
Keep motif runtime lib at 1.8
jbarr21 Feb 11, 2025
503040c
Update Kotlin & related dependencies to 2.1.0
jbarr21 Feb 11, 2025
df1af3d
Fixup gradle build files
jbarr21 Feb 11, 2025
4a35a55
Fix spotless config
jbarr21 Feb 11, 2025
8c576ec
Suppress function name lint check
jbarr21 Feb 11, 2025
904122a
Run KSP tests with KSP1
jbarr21 Feb 12, 2025
72e5782
Run auto-format using latest ktlint & ktfmt
jbarr21 Feb 12, 2025
6f47cbf
Cast to fix nullability compile issue
jbarr21 Feb 12, 2025
bb3b379
Delete accidental file
jbarr21 Feb 14, 2025
8f10ec5
Prepare for release v0.4.0-alpha06
jbarr21 Feb 14, 2025
e1fafcc
disable field init through the scope parameter
rysh88 Jul 2, 2025
b3f33c3
Add test code based on the previous assertion
TonyTangAndroid Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# 0.4.0-alpha06
* Add support for Kotlin 2.1.0

# 0.4.0-alpha05
* Set JvmVersion to 1.8

# 0.4.0-alpha04
* Update Dagger version

# 0.4.0-alpha03
* Update XProcessing version

# 0.4.0-alpha02
* Upgrade JavaPoet, KotlinPoet, & XProcessing

# 0.4.0-alpha01
* Initial support for KSP

# 0.3.8

* Throw CannotResolveType error when compiler cannot resolve it.
Expand Down
8 changes: 1 addition & 7 deletions ast/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
}

apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8

dependencies {
implementation deps.kotlin.stdlib
implementation deps.dagger

testImplementation deps.test.junit
testImplementation deps.test.truth
}

apply plugin: 'com.vanniktech.maven.publish'
9 changes: 3 additions & 6 deletions ast/src/main/kotlin/motif/ast/IrAnnotated.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ interface IrAnnotated {

val annotations: List<IrAnnotation>

fun hasAnnotation(annotationClass: KClass<out Annotation>): Boolean {
return annotations.any { it.matchesClass(annotationClass) }
}
fun hasAnnotation(annotationClass: KClass<out Annotation>): Boolean =
annotations.any { it.matchesClass(annotationClass) }

fun isNullable(): Boolean {
return annotations.any { it.className?.endsWith("Nullable") == true }
}
fun isNullable(): Boolean = annotations.any { it.className?.endsWith("Nullable") == true }
}
2 changes: 2 additions & 0 deletions ast/src/main/kotlin/motif/ast/IrAnnotation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ interface IrAnnotation : IrEquivalence {

val members: List<IrMethod>

val annotationValueMap: Map<String, Any?>

fun matchesClass(annotationClass: KClass<out Annotation>): Boolean
}
11 changes: 4 additions & 7 deletions ast/src/main/kotlin/motif/ast/IrClass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,13 @@ interface IrClass : IrAnnotated, IrHasModifiers {
val simpleName: String
get() = type.simpleName

fun hasNonDefaultConstructor(): Boolean {
return constructors.any { it.hasParameters() }
}
fun hasNonDefaultConstructor(): Boolean = constructors.any { it.hasParameters() }

fun annotatedInnerClass(annotationClass: KClass<out Annotation>): IrClass? {
return nestedClasses.find { it.hasAnnotation(annotationClass) }
}
fun annotatedInnerClass(annotationClass: KClass<out Annotation>): IrClass? =
nestedClasses.find { it.hasAnnotation(annotationClass) }

enum class Kind {
CLASS,
INTERFACE
INTERFACE,
}
}
16 changes: 4 additions & 12 deletions ast/src/main/kotlin/motif/ast/IrHasModifiers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,11 @@ interface IrHasModifiers {

val modifiers: Set<IrModifier>

fun isStatic(): Boolean {
return IrModifier.STATIC in modifiers
}
fun isStatic(): Boolean = IrModifier.STATIC in modifiers

fun isPrivate(): Boolean {
return IrModifier.PRIVATE in modifiers
}
fun isPrivate(): Boolean = IrModifier.PRIVATE in modifiers

fun isPublic(): Boolean {
return IrModifier.PUBLIC in modifiers
}
fun isPublic(): Boolean = IrModifier.PUBLIC in modifiers

fun isAbstract(): Boolean {
return IrModifier.ABSTRACT in modifiers
}
fun isAbstract(): Boolean = IrModifier.ABSTRACT in modifiers
}
8 changes: 2 additions & 6 deletions ast/src/main/kotlin/motif/ast/IrMethod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ interface IrMethod : IrAnnotated, IrHasModifiers {
val name: String
val isConstructor: Boolean

fun hasParameters(): Boolean {
return parameters.isNotEmpty()
}
fun hasParameters(): Boolean = parameters.isNotEmpty()

fun isVoid(): Boolean {
return returnType.isVoid
}
fun isVoid(): Boolean = returnType.isVoid
}
2 changes: 1 addition & 1 deletion ast/src/main/kotlin/motif/ast/IrModifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ enum class IrModifier {
VOLATILE,
DEFAULT,
OPEN,
TRANSITIVE
TRANSITIVE,
}
1 change: 1 addition & 0 deletions ast/src/main/kotlin/motif/ast/IrType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface IrType : IrEquivalence {
get() = simpleName(qualifiedName)

fun resolveClass(): IrClass?

fun isAssignableTo(type: IrType): Boolean
}

Expand Down
7 changes: 3 additions & 4 deletions ast/src/test/kotlin/motif/ast/SimpleNameTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ class SimpleNameTest(private val qualifiedName: String, private val expectedSimp
"java.util.List<? super java.lang.String>" to "List<? super String>",
"java.util.Map<java.lang.String, java.lang.Integer>" to "Map<String, Integer>",
"java.util.Map<? extends java.lang.String, ? super java.lang.Integer>" to
"Map<? extends String, ? super Integer>")
"Map<? extends String, ? super Integer>",
)

@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun data(): Collection<Array<Any>> {
return tests.map { (key, value) -> arrayOf<Any>(key, value) }
}
fun data(): Collection<Array<Any>> = tests.map { (key, value) -> arrayOf(key, value) }
}

@Test
Expand Down
60 changes: 55 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial

// https://github.com/gradle/gradle/issues/4848
gradle.startParameter.configureOnDemand = false

Expand All @@ -11,6 +13,7 @@ buildscript {
}
dependencies {
classpath deps.build.gradlePlugins.android
classpath deps.build.gradlePlugins.intellij
classpath deps.build.gradlePlugins.kotlin
classpath deps.build.gradlePlugins.ksp
classpath deps.build.gradlePlugins.dokka
Expand Down Expand Up @@ -39,6 +42,12 @@ subprojects {
useTarget(deps.autoCommon)
} else if (requested.group == "org.jetbrains.kotlinx" && requested.name == "kotlinx-metadata") {
useTarget(deps.kotlinxMetadata)
} else if (requested.group == "com.google.devtools.ksp") {
useVersion(deps.versions.ksp)
} else if (requested.group == "androidx.room") {
if (requested.name != "room-compiler-processing" && requested.name != "room-compiler-processing-testing") {
useVersion(deps.versions.room)
}
}
}
}
Expand All @@ -56,44 +65,85 @@ subprojects {
}
boolean isKotlinLibrary = project.plugins.hasPlugin("org.jetbrains.kotlin.jvm") || project.plugins.hasPlugin("org.jetbrains.kotlin.android")
if (isKotlinLibrary) {
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(11))
}
kotlin {
jvmToolchain(11)
}
it.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += extraKotlincArgs
}
}
}

boolean isAndroidLibraryOrApp = project.plugins.hasPlugin("org.jetbrains.kotlin.android")
if (isAndroidLibraryOrApp) {
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}
}

if (isKotlinLibrary && isAndroidLibraryOrApp) {
android {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
}

if (project.path != ":tests") {
apply plugin: 'com.diffplug.spotless'
spotless {
format 'misc', {
target '**/*.md', '**/.gitignore'
target '*.md', '.gitignore'

trimTrailingWhitespace()
endWithNewline()
}
kotlin {
target "**/*.kt"
ktlint(deps.versions.ktlint).userData(['indent_size': '2', 'continuation_indent_size': '2'])
target "src/**/*.kt"
ktlint(deps.versions.ktlint).editorConfigOverride([
"indent_size": "2",
"continuation_indent_size": "4"
])
suppressLintsFor {
step = 'ktlint'
shortCode = 'standard:function-naming'
}
ktfmt(deps.versions.ktfmt)
licenseHeaderFile rootProject.file('config/spotless/copyright.kt')
trimTrailingWhitespace()
endWithNewline()
}
java {
target "**/*.java"
target "src/**/*.java"
googleJavaFormat(deps.versions.gjf)
licenseHeaderFile rootProject.file('config/spotless/copyright.java')
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
groovyGradle {
target '**/*.gradle'
target '*.gradle'
trimTrailingWhitespace()
endWithNewline()
}
}
}

apply plugin: 'org.jetbrains.dokka'
if (!project.name.contains("samples") && !project.name.contains("tests")) {
tasks.withType(DokkaTaskPartial).configureEach {
outputDirectory.set(new File(buildDir, "docs/partial"))
moduleName.set(project.property("POM_ARTIFACT_ID").toString())
moduleVersion.set(project.property("VERSION_NAME").toString())
}
}
}
9 changes: 1 addition & 8 deletions compiler/ast/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'com.vanniktech.maven.publish'
}

apply plugin: 'kotlin-kapt'

sourceCompatibility = 1.8


dependencies {
implementation deps.kotlin.stdlib
implementation deps.autoCommon
Expand All @@ -22,5 +17,3 @@ dependencies {
testImplementation deps.test.compileTesting
testImplementation deps.test.roomCompilerProcessingTesting
}

apply plugin: 'com.vanniktech.maven.publish'
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,23 @@ import com.google.auto.common.AnnotationMirrors
* Used to find equivalence of two XAnnotation since AnnotationMirrors.equivalence() only applies to
* the Javac backend.
*/
fun XAnnotation.isEquivalent(other: XAnnotation, env: XProcessingEnv): Boolean {
return if (env.backend == XProcessingEnv.Backend.JAVAC) {
val key = AnnotationMirrors.equivalence().wrap(this.toJavac())
val otherKey = AnnotationMirrors.equivalence().wrap(other.toJavac())
key == otherKey
} else {
(type.isEquivalent(other.type, env) &&
annotationValues.size == other.annotationValues.size &&
annotationValues.zip(other.annotationValues).all { (lhs, rhs) -> lhs.isEquivalent(rhs) })
}
}
fun XAnnotation.isEquivalent(other: XAnnotation, env: XProcessingEnv): Boolean =
if (env.backend == XProcessingEnv.Backend.JAVAC) {
val key = AnnotationMirrors.equivalence().wrap(this.toJavac())
val otherKey = AnnotationMirrors.equivalence().wrap(other.toJavac())
key == otherKey
} else {
(type.isEquivalent(other.type, env) &&
annotationValues.size == other.annotationValues.size &&
annotationValues.zip(other.annotationValues).all { (lhs, rhs) -> lhs.isEquivalent(rhs) })
}

/**
* Used to find equivalence of two XAnnotation since AnnotationMirrors.equivalence() only applies to
* the Javac backend.
*/
fun XAnnotationValue.isEquivalent(other: XAnnotationValue): Boolean {
return this.name == other.name && this.value == other.value
}
fun XAnnotationValue.isEquivalent(other: XAnnotationValue): Boolean =
this.name == other.name && this.value == other.value

/** Cleans up differences in the toString() methods between the JAVAC and KSP backends. */
fun XAnnotation.toPrettyString(): String {
Expand All @@ -55,7 +53,9 @@ fun XAnnotation.toPrettyString(): String {
.map {
if (it.name == "value") {
"\"${it.value}\""
} else "${it.name} = ${it.value}"
} else {
"${it.name} = ${it.value}"
}
}
.joinToString(", ")
val annotationValuesList =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ val XElement.modifiers: List<Modifier>
if (isFinal()) modifiers += Modifier.FINAL
if (isTransient()) modifiers += Modifier.TRANSIENT
return@let modifiers
}
?: emptyList()
} ?: emptyList()
}

val XElement.modifierNames: List<String>
get() = modifiers.map { it.name }

fun XHasModifiers.isPackagePrivate(): Boolean {
return !isPrivate() && !isProtected() && !isPublic()
}
fun XHasModifiers.isPackagePrivate(): Boolean = !isPrivate() && !isProtected() && !isPublic()
Loading
Loading