Skip to content

Commit

Permalink
Merge branch 'main' into z/moduleName
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Apr 17, 2024
2 parents 04000e0 + cf3b401 commit 6d1839a
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: 1.0.20-release
ref: 1.0.21-release

- name: merge commits from main to release branch
run: |
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: 1.0.20-release
ref: 1.0.21-release

- name: merge commits from main to release branch
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: CI

on:
push:
branches: [ main, 1.0.20-release, 1.0.19-release ]
branches: [ main, 1.0.20-release, 1.0.21-release ]
pull_request:
branches: [ main, 1.0.20-release, 1.0.19-release ]
branches: [ main, 1.0.20-release, 1.0.21-release ]

jobs:
build-and-test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
branch: [ main, 1.0.19-release, 1.0.20-release ]
branch: [ main, 1.0.21-release, 1.0.20-release ]
runs-on: windows-latest
steps:
- name: configure Pagefile
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Copied from kotlinc
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx2200m -Dfile.encoding=UTF-8

kotlinBaseVersion=2.0.0-dev-19480
kotlinBaseVersion=2.0.20-dev-715
agpBaseVersion=7.2.0
intellijVersion=213.7172.25
junitVersion=4.13.1
junit5Version=5.8.2
junitPlatformVersion=1.8.2
googleTruthVersion=1.1

aaKotlinBaseVersion=2.0.0-dev-19480
aaKotlinBaseVersion=2.0.20-dev-715
aaIntellijVersion=213.7172.25
aaGuavaVersion=29.0-jre
aaAsmVersion=9.0
Expand Down
32 changes: 31 additions & 1 deletion kotlin-analysis-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.ByteArrayOutputStream

description = "Kotlin Symbol Processing implementation using Kotlin Analysis API"

Expand All @@ -23,6 +24,7 @@ plugins {
}

val depSourceJars by configurations.creating
val depJarsForCheck by configurations.creating

dependencies {
listOf(
Expand Down Expand Up @@ -84,13 +86,18 @@ dependencies {
) {
isTransitive = false
}
implementation("org.jetbrains:annotations:24.1.0")

compileOnly(project(":common-deps"))

implementation(project(":api"))
implementation(project(":common-util"))

testImplementation(kotlin("stdlib", aaKotlinBaseVersion))

depJarsForCheck("org.jetbrains.kotlin", "kotlin-stdlib", aaKotlinBaseVersion)
depJarsForCheck(project(":api"))
depJarsForCheck(project(":common-deps"))
}

sourceSets.main {
Expand Down Expand Up @@ -121,8 +128,31 @@ tasks.withType<ShadowJar>() {
}
exclude("kotlin/**")
archiveClassifier.set("")
minimize()
minimize {
exclude(dependency("org.lz4:lz4-java:.*"))
}
mergeServiceFiles()

doLast {
// Checks for missing dependencies
val jarJar = archiveFile.get().asFile
val depJars = depJarsForCheck.resolve().map(File::getPath)
val stdout = ByteArrayOutputStream()
try {
exec {
executable = "jdeps"
args = listOf(
"--multi-release", "base",
"--missing-deps",
"-cp", depJars.joinToString(":"), jarJar.path
)
standardOutput = stdout
}
} catch (e: org.gradle.process.internal.ExecException) {
logger.warn(e.message)
}
logger.warn(stdout.toString())
}
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,15 @@ internal val DEAR_SHADOW_JAR_PLEASE_DO_NOT_REMOVE_THESE = listOf(
org.jetbrains.kotlin.load.java.ErasedOverridabilityCondition::class.java,
org.jetbrains.kotlin.load.java.FieldOverridabilityCondition::class.java,
org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInsLoaderImpl::class.java,
com.fasterxml.aalto.AaltoInputProperties::class.java,
com.google.errorprone.annotations.CheckReturnValue::class.java,
com.intellij.openapi.application.JetBrainsProtocolHandler::class.java,
com.intellij.openapi.editor.impl.EditorDocumentPriorities::class.java,
com.intellij.psi.tree.ChildRoleBase::class.java,
com.intellij.util.xmlb.Constants::class.java,
com.intellij.xml.CommonXmlStrings::class.java,
org.codehaus.stax2.XMLInputFactory2::class.java,
org.codehaus.stax2.XMLStreamProperties::class.java,
)

fun TargetPlatform.getPlatformInfo(kspConfig: KSPConfig): List<PlatformInfo> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ internal inline fun <R> analyze(crossinline action: KtAnalysisSession.() -> R):
internal fun KtSymbolWithMembers.declarations(): Sequence<KSDeclaration> {
return analyze {
this@declarations.let {
it.getDeclaredMemberScope().getAllSymbols() + it.getStaticMemberScope().getAllSymbols()
it.getDeclaredMemberScope().getAllSymbols() + it.getStaticDeclaredMemberScope().getAllSymbols()
}.distinct().map { symbol ->
when (symbol) {
is KtNamedClassOrObjectSymbol -> KSClassDeclarationImpl.getCached(symbol)
Expand Down Expand Up @@ -349,7 +349,11 @@ internal fun KtType.classifierSymbol(): KtClassifierSymbol? {
}

internal fun KtType.typeArguments(): List<KtTypeProjection> {
return (this as? KtNonErrorClassType)?.qualifiers?.reversed()?.flatMap { it.typeArguments } ?: emptyList()
return if (this is KtFlexibleType) {
this.lowerBound
} else {
this
}.let { (it as? KtNonErrorClassType)?.qualifiers?.reversed()?.flatMap { it.typeArguments } ?: emptyList() }
}

internal fun KSAnnotated.findAnnotationFromUseSiteTarget(): Sequence<KSAnnotation> {
Expand Down
6 changes: 6 additions & 0 deletions kotlin-analysis-api/testData/replaceWithErrorTypeArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
// KLE.E.asType(emptyList()): KLE
// default type:A
// flexible type star:T
// flexible type replace argument:JS1<Int>
// END

// MODULE: lib
Expand All @@ -123,6 +124,10 @@ class JS<T1, T2> {}
class JS1<T> {
T p;
}

class JavaClass {
JS1<?> p;
}
enum JSE {
E
}
Expand All @@ -137,3 +142,4 @@ enum class KSE {

val x: KS<Int, String> = TODO()
val y: KS<NotExist1, NotExist2> = TODO()
val z: KL1<Int> = TODO()
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.google.devtools.ksp.processor

import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.getDeclaredFunctions
import com.google.devtools.ksp.getDeclaredProperties
import com.google.devtools.ksp.isAbstract
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.KSAnnotated
Expand Down Expand Up @@ -100,6 +101,9 @@ class DefaultFunctionProcessor : AbstractTestProcessor() {
result.add("${aProperty.simpleName.asString()}: ${aProperty.isAbstract()}")
val D = resolver.getClassDeclarationByName("D")!!
D.getAllProperties().forEach { result.add("${it.simpleName.asString()}: isMutable: ${it.isMutable}") }
resolver.getClassDeclarationByName("JavaDerived")!!.getDeclaredProperties().forEach {
result.add(it.toString())
}
return emptyList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ open class ReplaceWithErrorTypeArgsProcessor : AbstractTestProcessor() {
val xargs = x.type.element!!.typeArguments
val y = resolver.getPropertyDeclarationByName(resolver.getKSNameFromString("y"), true)!!
val yargs = y.type.element!!.typeArguments
val z = resolver.getPropertyDeclarationByName(resolver.getKSNameFromString("z"), true)!!
val zargs = z.type.element!!.typeArguments

for (decl in decls) {
val declName = decl.qualifiedName!!.asString()
Expand All @@ -64,6 +66,9 @@ open class ReplaceWithErrorTypeArgsProcessor : AbstractTestProcessor() {
// TODO: fix flexible type creation once upstream available.
val js1 = resolver.getClassDeclarationByName("JS1")!!
results.add("flexible type star:${js1.getDeclaredProperties().single().type.resolve().starProjection()}")
val javaClass = resolver.getClassDeclarationByName("JavaClass")!!
val genericFlexibleProperty = javaClass.getDeclaredProperties().single().type.resolve()
results.add("flexible type replace argument:${genericFlexibleProperty.replace(zargs)}")
return emptyList()
}

Expand Down
10 changes: 10 additions & 0 deletions test-utils/testData/api/interfaceWithDefault.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ class D {

final int finalField;
}

// FILE: JavaBase.java

class JavaBase {
static String staticField;
}

// FILE: JavaDerived.java
class JavaDerived extends JavaBase {
}
6 changes: 6 additions & 0 deletions test-utils/testData/api/replaceWithErrorTypeArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
// KLE.E.asType(emptyList()): KLE.E
// default type:A
// flexible type star:(T..T?)
// flexible type replace argument:(JS1<Int>..JS1<Int>?)
// END

// MODULE: lib
Expand All @@ -123,6 +124,10 @@ class JS<T1, T2> {}
class JS1<T> {
T p;
}

class JavaClass {
JS1<?> p;
}
enum JSE {
E
}
Expand All @@ -137,3 +142,4 @@ enum class KSE {

val x: KS<Int, String> = TODO()
val y: KS<NotExist1, NotExist2> = TODO()
val z: KL1<Int> = TODO()

0 comments on commit 6d1839a

Please sign in to comment.