-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert ClassUsageRecorder & checker objects to classes
- Loading branch information
Showing
12 changed files
with
111 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
...ain/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/declaration/BasicDeclarationChecker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
package io.bazel.kotlin.plugin.jdeps.k2.checker.declaration | ||
|
||
import io.bazel.kotlin.plugin.jdeps.k2.recordClass | ||
import io.bazel.kotlin.plugin.jdeps.k2.ClassUsageRecorder | ||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter | ||
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind | ||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext | ||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker | ||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration | ||
import org.jetbrains.kotlin.fir.declarations.toAnnotationClassLikeSymbol | ||
|
||
internal object BasicDeclarationChecker : FirBasicDeclarationChecker(MppCheckerKind.Common) { | ||
internal class BasicDeclarationChecker( | ||
private val classUsageRecorder: ClassUsageRecorder, | ||
) : FirBasicDeclarationChecker(MppCheckerKind.Common) { | ||
override fun check( | ||
declaration: FirDeclaration, | ||
context: CheckerContext, | ||
reporter: DiagnosticReporter, | ||
) { | ||
declaration.annotations.forEach { annotation -> | ||
annotation.toAnnotationClassLikeSymbol(context.session)?.recordClass(context) | ||
annotation.toAnnotationClassLikeSymbol(context.session)?.let { | ||
classUsageRecorder.recordClass(it, context) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/checker/declaration/ClassLikeChecker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
package io.bazel.kotlin.plugin.jdeps.k2.checker.declaration | ||
|
||
import io.bazel.kotlin.plugin.jdeps.k2.recordClass | ||
import io.bazel.kotlin.plugin.jdeps.k2.recordConeType | ||
import io.bazel.kotlin.plugin.jdeps.k2.ClassUsageRecorder | ||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter | ||
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind | ||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext | ||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirClassLikeChecker | ||
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration | ||
import org.jetbrains.kotlin.fir.resolve.getSuperTypes | ||
|
||
internal object ClassLikeChecker : FirClassLikeChecker(MppCheckerKind.Common) { | ||
internal class ClassLikeChecker( | ||
private val classUsageRecorder: ClassUsageRecorder, | ||
) : FirClassLikeChecker(MppCheckerKind.Common) { | ||
override fun check( | ||
declaration: FirClassLikeDeclaration, | ||
context: CheckerContext, | ||
reporter: DiagnosticReporter, | ||
) { | ||
declaration.symbol.recordClass(context) | ||
declaration.symbol.let { classUsageRecorder.recordClass(it, context) } | ||
// [recordClass] also handles supertypes, but this marks direct supertypes as explicit | ||
declaration.symbol.getSuperTypes(context.session, recursive = false).forEach { | ||
it.recordConeType(context) | ||
classUsageRecorder.recordConeType(it, context) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.