Reformat AbstractSimpleFileBenchmark.kt
This commit is contained in:
@@ -66,10 +66,10 @@ private val JDK_PATH = File("${System.getProperty("java.home")!!}/lib/rt.jar")
|
||||
private val RUNTIME_JAR = File(System.getProperty("kotlin.runtime.path") ?: "dist/kotlinc/lib/kotlin-runtime.jar")
|
||||
|
||||
private val LANGUAGE_FEATURE_SETTINGS =
|
||||
LanguageVersionSettingsImpl(
|
||||
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
||||
specificFeatures = mapOf(LanguageFeature.NewInference to LanguageFeature.State.ENABLED)
|
||||
)
|
||||
LanguageVersionSettingsImpl(
|
||||
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
||||
specificFeatures = mapOf(LanguageFeature.NewInference to LanguageFeature.State.ENABLED)
|
||||
)
|
||||
|
||||
private fun newConfiguration(useNewInference: Boolean): CompilerConfiguration {
|
||||
val configuration = CompilerConfiguration()
|
||||
@@ -81,10 +81,10 @@ private fun newConfiguration(useNewInference: Boolean): CompilerConfiguration {
|
||||
|
||||
val newInferenceState = if (useNewInference) LanguageFeature.State.ENABLED else LanguageFeature.State.DISABLED
|
||||
configuration.languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
||||
specificFeatures = mapOf(
|
||||
LanguageFeature.NewInference to newInferenceState
|
||||
)
|
||||
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
||||
specificFeatures = mapOf(
|
||||
LanguageFeature.NewInference to newInferenceState
|
||||
)
|
||||
)
|
||||
return configuration
|
||||
}
|
||||
@@ -105,21 +105,21 @@ abstract class AbstractSimpleFileBenchmark {
|
||||
fun setUp() {
|
||||
if (isIR && !useNewInference) error("Invalid configuration")
|
||||
env = KotlinCoreEnvironment.createForTests(
|
||||
myDisposable,
|
||||
newConfiguration(useNewInference),
|
||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
myDisposable,
|
||||
newConfiguration(useNewInference),
|
||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||
)
|
||||
|
||||
if (isIR) {
|
||||
Extensions.getArea(env.project)
|
||||
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
||||
.unregisterExtension(JavaElementFinder::class.java)
|
||||
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
||||
.unregisterExtension(JavaElementFinder::class.java)
|
||||
}
|
||||
|
||||
file = createFile(
|
||||
"test.kt",
|
||||
buildText(),
|
||||
env.project
|
||||
"test.kt",
|
||||
buildText(),
|
||||
env.project
|
||||
)
|
||||
}
|
||||
|
||||
@@ -134,22 +134,22 @@ abstract class AbstractSimpleFileBenchmark {
|
||||
private fun analyzeGreenFileFrontend(bh: Blackhole) {
|
||||
val tracker = ExceptionTracker()
|
||||
val storageManager: StorageManager =
|
||||
LockBasedStorageManager.createWithExceptionHandling("benchmarks", tracker)
|
||||
LockBasedStorageManager.createWithExceptionHandling("benchmarks", tracker)
|
||||
|
||||
val context = SimpleGlobalContext(storageManager, tracker)
|
||||
val module =
|
||||
ModuleDescriptorImpl(
|
||||
Name.special("<benchmark>"), storageManager,
|
||||
JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
|
||||
)
|
||||
ModuleDescriptorImpl(
|
||||
Name.special("<benchmark>"), storageManager,
|
||||
JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
|
||||
)
|
||||
val moduleContext = context.withProject(env.project).withModule(module)
|
||||
|
||||
val result = TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||
moduleContext.project,
|
||||
listOf(file),
|
||||
NoScopeRecordCliBindingTrace(),
|
||||
env.configuration,
|
||||
{ scope -> JvmPackagePartProvider(LANGUAGE_FEATURE_SETTINGS, scope) }
|
||||
moduleContext.project,
|
||||
listOf(file),
|
||||
NoScopeRecordCliBindingTrace(),
|
||||
env.configuration,
|
||||
{ scope -> JvmPackagePartProvider(LANGUAGE_FEATURE_SETTINGS, scope) }
|
||||
)
|
||||
|
||||
assert(result.bindingContext.diagnostics.none { it.severity == Severity.ERROR })
|
||||
@@ -159,7 +159,7 @@ abstract class AbstractSimpleFileBenchmark {
|
||||
|
||||
private fun analyzeGreenFileIr(bh: Blackhole) {
|
||||
val scope = GlobalSearchScope.filesScope(env.project, listOf(file.virtualFile))
|
||||
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(env.project))
|
||||
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(env.project))
|
||||
val session = createSession(env, scope)
|
||||
val firProvider = session.firProvider as FirProviderImpl
|
||||
val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider, stubMode = false)
|
||||
@@ -176,9 +176,9 @@ abstract class AbstractSimpleFileBenchmark {
|
||||
}
|
||||
|
||||
fun createSession(
|
||||
environment: KotlinCoreEnvironment,
|
||||
sourceScope: GlobalSearchScope,
|
||||
librariesScope: GlobalSearchScope = GlobalSearchScope.notScope(sourceScope)
|
||||
environment: KotlinCoreEnvironment,
|
||||
sourceScope: GlobalSearchScope,
|
||||
librariesScope: GlobalSearchScope = GlobalSearchScope.notScope(sourceScope)
|
||||
): FirSession {
|
||||
val moduleInfo = FirTestModuleInfo()
|
||||
val project = environment.project
|
||||
@@ -189,24 +189,24 @@ fun createSession(
|
||||
}
|
||||
|
||||
private fun createSessionForDependencies(
|
||||
provider: FirProjectSessionProvider,
|
||||
moduleInfo: FirTestModuleInfo,
|
||||
librariesScope: GlobalSearchScope,
|
||||
environment: KotlinCoreEnvironment
|
||||
provider: FirProjectSessionProvider,
|
||||
moduleInfo: FirTestModuleInfo,
|
||||
librariesScope: GlobalSearchScope,
|
||||
environment: KotlinCoreEnvironment
|
||||
) {
|
||||
val dependenciesInfo = FirTestModuleInfo()
|
||||
moduleInfo.dependencies.add(dependenciesInfo)
|
||||
FirLibrarySession.create(
|
||||
dependenciesInfo, provider, librariesScope, environment.project,
|
||||
environment.createPackagePartProvider(librariesScope)
|
||||
dependenciesInfo, provider, librariesScope, environment.project,
|
||||
environment.createPackagePartProvider(librariesScope)
|
||||
)
|
||||
}
|
||||
|
||||
class FirTestModuleInfo(
|
||||
override val name: Name = Name.identifier("TestModule"),
|
||||
val dependencies: MutableList<ModuleInfo> = mutableListOf(),
|
||||
override val platform: TargetPlatform = JvmPlatforms.unspecifiedJvmPlatform,
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices = JvmPlatformAnalyzerServices
|
||||
override val name: Name = Name.identifier("TestModule"),
|
||||
val dependencies: MutableList<ModuleInfo> = mutableListOf(),
|
||||
override val platform: TargetPlatform = JvmPlatforms.unspecifiedJvmPlatform,
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices = JvmPlatformAnalyzerServices
|
||||
) : ModuleInfo {
|
||||
override fun dependencies(): List<ModuleInfo> = dependencies
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user