• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.tools.metalava.model.turbine
18 
19 import com.android.tools.metalava.model.DefaultAnnotationItem
20 import com.android.tools.metalava.model.DefaultItem
21 import com.android.tools.metalava.model.item.DefaultCodebase
22 import com.android.tools.metalava.model.item.DefaultItemFactory
23 import com.google.turbine.binder.bound.SourceTypeBoundClass
24 import com.google.turbine.binder.bound.TypeBoundClass
25 import com.google.turbine.binder.sym.ClassSymbol
26 import com.google.turbine.type.AnnoInfo
27 
28 /** Global context that is shared between [TurbineCodebaseInitialiser] and [TurbineClassBuilder]. */
29 internal interface TurbineGlobalContext {
30     /** The [DefaultCodebase] being built. */
31     val codebase: DefaultCodebase
32 
33     /** Cache of [TurbineSourceFile]s. */
34     val sourceFileCache: TurbineSourceFileCache
35 
36     /** Factory for creating [DefaultItem] implementations. */
37     val itemFactory: DefaultItemFactory
38 
39     /** Factory for creating [DefaultAnnotationItem]s from [AnnoInfo] objects. */
40     val annotationFactory: TurbineAnnotationFactory
41 
42     /** True if comments should be read, false otherwise. */
43     val allowReadingComments: Boolean
44 
45     /** Find the [TypeBoundClass] for the `ClassSymbol`. */
typeBoundClassForSymbolnull46     fun typeBoundClassForSymbol(classSymbol: ClassSymbol): TypeBoundClass
47 
48     /**
49      * Create a [TurbineFieldResolver] for resolving fields from within
50      * [classSymbol]/[sourceTypeBoundClass].
51      */
52     fun createFieldResolver(
53         classSymbol: ClassSymbol,
54         sourceTypeBoundClass: SourceTypeBoundClass,
55     ): TurbineFieldResolver
56 }
57