Analysis API: introduce Project Structure
This commit is contained in:
@@ -7,6 +7,7 @@ dependencies {
|
||||
implementation(project(":compiler:psi"))
|
||||
implementation(project(":compiler:frontend.java"))
|
||||
implementation(project(":core:compiler.common"))
|
||||
implementation(project(":analysis:project-structure"))
|
||||
implementation(intellijCoreDep()) { includeJars("intellij-core", rootProject = rootProject) }
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -9,11 +9,11 @@ import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
|
||||
|
||||
public abstract class KotlinModificationTrackerFactory {
|
||||
public abstract fun createProjectWideOutOfBlockModificationTracker(): ModificationTracker
|
||||
public abstract fun createModuleWithoutDependenciesOutOfBlockModificationTracker(moduleInfo: ModuleSourceInfoBase): ModificationTracker
|
||||
public abstract fun createModuleWithoutDependenciesOutOfBlockModificationTracker(module: KtSourceModule): ModificationTracker
|
||||
public abstract fun createLibrariesModificationTracker(): ModificationTracker
|
||||
|
||||
@TestOnly
|
||||
@@ -29,6 +29,6 @@ public fun Project.createLibrariesModificationTracker(): ModificationTracker =
|
||||
.createLibrariesModificationTracker()
|
||||
|
||||
|
||||
public fun ModuleSourceInfoBase.createModuleWithoutDependenciesOutOfBlockModificationTracker(project: Project): ModificationTracker =
|
||||
public fun KtSourceModule.createModuleWithoutDependenciesOutOfBlockModificationTracker(project: Project): ModificationTracker =
|
||||
ServiceManager.getService(project, KotlinModificationTrackerFactory::class.java)
|
||||
.createModuleWithoutDependenciesOutOfBlockModificationTracker(this)
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analysis.providers
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
public abstract class KotlinModuleInfoProvider {
|
||||
public abstract fun getModuleInfo(element: KtElement): ModuleInfo
|
||||
}
|
||||
|
||||
public fun KtElement.getModuleInfo(): ModuleInfo =
|
||||
ServiceManager.getService(project, KotlinModuleInfoProvider::class.java).getModuleInfo(this)
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
public abstract class KotlinPackageProvider {
|
||||
public abstract fun isPackageExists(packageFqName: FqName): Boolean
|
||||
public abstract fun doKotlinPackageExists(packageFqName: FqName): Boolean
|
||||
public abstract fun getKotlinSubPackageFqNames(packageFqName: FqName): Set<Name>
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -8,21 +8,21 @@ package org.jetbrains.kotlin.analysis.providers.impl
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import com.intellij.openapi.util.SimpleModificationTracker
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
|
||||
import org.jetbrains.kotlin.analysis.providers.KotlinModificationTrackerFactory
|
||||
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
|
||||
|
||||
public class KotlinStaticModificationTrackerFactory : KotlinModificationTrackerFactory() {
|
||||
private val projectWide = SimpleModificationTracker()
|
||||
private val library = SimpleModificationTracker()
|
||||
private val forModule = mutableMapOf<ModuleSourceInfoBase, SimpleModificationTracker>()
|
||||
private val forModule = mutableMapOf<KtSourceModule, SimpleModificationTracker>()
|
||||
|
||||
override fun createProjectWideOutOfBlockModificationTracker(): ModificationTracker {
|
||||
return projectWide
|
||||
}
|
||||
|
||||
|
||||
override fun createModuleWithoutDependenciesOutOfBlockModificationTracker(moduleInfo: ModuleSourceInfoBase): ModificationTracker {
|
||||
return forModule.getOrPut(moduleInfo) { SimpleModificationTracker() }
|
||||
override fun createModuleWithoutDependenciesOutOfBlockModificationTracker(module: KtSourceModule): ModificationTracker {
|
||||
return forModule.getOrPut(module) { SimpleModificationTracker() }
|
||||
}
|
||||
|
||||
override fun createLibrariesModificationTracker(): ModificationTracker {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class KotlinStaticPackageProvider(
|
||||
packages
|
||||
}
|
||||
|
||||
override fun isPackageExists(packageFqName: FqName): Boolean {
|
||||
override fun doKotlinPackageExists(packageFqName: FqName): Boolean {
|
||||
return packageFqName in packageToSubPackageNames
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user