1 /*
2  * Copyright (C) 2023 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.source
18 
19 import com.android.tools.metalava.model.AnnotationManager
20 import com.android.tools.metalava.model.ModelOptions
21 import com.android.tools.metalava.reporter.Reporter
22 import java.io.Closeable
23 import java.io.File
24 
25 /**
26  * Manages environmental resources, e.g. temporary directories, file caches, etc. needed while
27  * processing source files.
28  *
29  * This will clean up any resources on [close].
30  */
31 interface EnvironmentManager : Closeable {
32 
33     /**
34      * Create a [SourceParser] that can be used to create [SourceCodebase] related objects.
35      *
36      * @param reporter the [Reporter] to use for any issues found while processing the sources.
37      * @param annotationManager the [AnnotationManager] that determines how annotations will affect
38      *   any generated [SourceCodebase]s.
39      * @param javaLanguageLevel the java language level as a string, e.g. 1.8, 17, etc.
40      * @param kotlinLanguageLevel the kotlin language level as a string, e.g. 1.8, etc.
41      * @param modelOptions a set of model specific options provided by the caller.
42      * @param jdkHome the optional path to the jdk home directory.
43      */
createSourceParsernull44     fun createSourceParser(
45         reporter: Reporter,
46         annotationManager: AnnotationManager,
47         javaLanguageLevel: String = DEFAULT_JAVA_LANGUAGE_LEVEL,
48         kotlinLanguageLevel: String = DEFAULT_KOTLIN_LANGUAGE_LEVEL,
49         modelOptions: ModelOptions = ModelOptions.empty,
50         allowReadingComments: Boolean = true,
51         jdkHome: File? = null,
52     ): SourceParser
53 }
54 
55 const val DEFAULT_JAVA_LANGUAGE_LEVEL = "1.8"
56 const val DEFAULT_KOTLIN_LANGUAGE_LEVEL = "1.9"
57