Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparations before reading Java annotations #388

Merged
merged 6 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 13 additions & 14 deletions tasty-query/shared/src/main/scala/tastyquery/reader/Loaders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import tastyquery.Symbols.*
import tastyquery.Trees.*

import tastyquery.reader.ReaderContext.rctx
import tastyquery.reader.classfiles.ClassfileParser
import tastyquery.reader.classfiles.{ClassfileParser, ClassfileReader}
import tastyquery.reader.classfiles.ClassfileParser.{ClassKind, InnerClassDecl, Resolver}
import tastyquery.reader.tasties.TastyUnpickler

Expand Down Expand Up @@ -93,16 +93,17 @@ private[tastyquery] object Loaders {
end innerClassLookup

def inspectClass(root: Loader.Root, classData: ClassData, entry: Entry): Unit =
ClassfileParser.readKind(root.pkg, classData) match
case ClassKind.Scala2(structure, runtimeAnnotStart) =>
ClassfileParser.loadScala2Class(structure, runtimeAnnotStart)
case ClassKind.Java(structure, sig, optInnerClasses) =>
val structure = ClassfileReader.readStructure(root.pkg, classData)
val kind = ClassfileParser.detectClassKind(structure)
kind match
case ClassKind.Scala2 =>
ClassfileParser.loadScala2Class(structure)
case ClassKind.Java =>
entry match
case Entry.ClassOnly(_, nested) =>
val lookup = innerClassLookup(nested)
val innerDecls =
ClassfileParser.loadJavaClass(root.pkg, root.rootName, structure, sig, lookup, optInnerClasses)
if innerDecls.nonEmpty then enterInners(innerDecls, lookup)
val innerDecls = ClassfileParser.loadJavaClass(root.pkg, root.rootName, structure, lookup)
enterInners(innerDecls, lookup)
case _ => throw UnexpectedTasty(root)
case ClassKind.TASTy =>
entry match
Expand Down Expand Up @@ -136,12 +137,10 @@ private[tastyquery] object Loaders {

explore match
case inner :: rest =>
ClassfileParser.readKind(inner.owner, inner.classData) match
case ClassKind.Java(structure, sig, inners) =>
val innerDecls = ClassfileParser.loadJavaClass(inner.owner, inner.name, structure, sig, lookup, inners)
enterInners(rest ::: innerDecls, lookup)
case kind => throw unexpectedClassKind(kind, inner)
case nil =>
val structure = ClassfileReader.readStructure(inner.owner, inner.classData)
val innerDecls = ClassfileParser.loadJavaClass(inner.owner, inner.name, structure, lookup)
enterInners(rest ::: innerDecls, lookup)
case Nil =>
()
end enterInners

Expand Down
Loading