aboutsummaryrefslogtreecommitdiff
path: root/src/Analysis
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-10-13 20:14:45 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-10-13 20:14:45 +0400
commit1cb3af902c8f2e3f73e7c78781373f1ab5788772 (patch)
tree88aaa6a10f0da26d28e9c2792313a2a11cf28356 /src/Analysis
parentefd1947722587d15bf1c81a0fd7ca722a7bc6fa8 (diff)
downloaddokka-1cb3af902c8f2e3f73e7c78781373f1ab5788772.tar.gz
dokka-1cb3af902c8f2e3f73e7c78781373f1ab5788772.tar.bz2
dokka-1cb3af902c8f2e3f73e7c78781373f1ab5788772.zip
Remove BindingContext and migrate to ResolveSession, discover symbols for {code ...} directive.
Diffstat (limited to 'src/Analysis')
-rw-r--r--src/Analysis/AnalysisEnvironment.kt37
-rw-r--r--src/Analysis/CommentsAPI.kt4
-rw-r--r--src/Analysis/CompilerAPI.kt4
3 files changed, 17 insertions, 28 deletions
diff --git a/src/Analysis/AnalysisEnvironment.kt b/src/Analysis/AnalysisEnvironment.kt
index 90231b84..3c7f6767 100644
--- a/src/Analysis/AnalysisEnvironment.kt
+++ b/src/Analysis/AnalysisEnvironment.kt
@@ -11,6 +11,7 @@ import org.jetbrains.jet.cli.common.*
import org.jetbrains.jet.cli.jvm.*
import com.intellij.openapi.util.*
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
+import org.jetbrains.jet.lang.resolve.lazy.ResolveSession
/**
* Kotlin as a service entry point
@@ -30,28 +31,28 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A
* Executes [processor] when analysis is complete.
* $processor is a function to receive compiler environment, module and context for symbol resolution
*/
- public fun withContext<T>(processor: (JetCoreEnvironment, ModuleDescriptor, BindingContext) -> T): T {
+ public fun withContext<T>(processor: (JetCoreEnvironment, ResolveSession) -> T): T {
val environment = JetCoreEnvironment.createForProduction(this, configuration)
val resolveSession = environment.analyze()
resolveSession.forceResolveAll()
- return processor(environment, resolveSession.getModuleDescriptor(), resolveSession.getBindingContext())
+ return processor(environment, resolveSession)
}
/**
* Executes [processor] when analysis is complete.
* $processor is a function to receive compiler module and context for symbol resolution
*/
- public fun withContext<T>(processor: (ModuleDescriptor, BindingContext) -> T): T {
- return withContext { environment, module, context -> processor(module, context) }
+ public fun withContext<T>(processor: (ResolveSession) -> T): T {
+ return withContext { environment, session -> processor(session) }
}
/**
* Streams files into [processor] and returns a stream of its results
* $processor is a function to receive context for symbol resolution and file for processing
*/
- public fun streamFiles<T>(processor: (BindingContext, JetFile) -> T): Stream<T> {
- return withContext { environment, module, context ->
- environment.getSourceFiles().stream().map { file -> processor(context, file) }
+ public fun streamFiles<T>(processor: (ResolveSession, JetFile) -> T): Stream<T> {
+ return withContext { environment, session ->
+ environment.getSourceFiles().stream().map { file -> processor(session, file) }
}
}
@@ -59,19 +60,9 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A
* Runs [processor] for each file and collects its results into single list
* $processor is a function to receive context for symbol resolution and file for processing
*/
- public fun processFiles<T>(processor: (BindingContext, JetFile) -> T): List<T> {
- return withContext { environment, module, context ->
- environment.getSourceFiles().map { file -> processor(context, file) }
- }
- }
-
- /**
- * Runs [processor] for each file and collects its results into single list
- * $processor is a function to receive context for symbol resolution, module and file for processing
- */
- public fun processFiles<T>(processor: (BindingContext, ModuleDescriptor, JetFile) -> T): List<T> {
- return withContext { environment, module, context ->
- environment.getSourceFiles().map { file -> processor(context, module, file) }
+ public fun processFiles<T>(processor: (ResolveSession, JetFile) -> T): List<T> {
+ return withContext { environment, session ->
+ environment.getSourceFiles().map { file -> processor(session, file) }
}
}
@@ -79,9 +70,9 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A
* Runs [processor] for each file and collects its results into single list
* $processor is a function to receive context for symbol resolution and file for processing
*/
- public fun processFilesFlat<T>(processor: (BindingContext, JetFile) -> List<T>): List<T> {
- return withContext { environment, module, context ->
- environment.getSourceFiles().flatMap { file -> processor(context, file) }
+ public fun processFilesFlat<T>(processor: (ResolveSession, JetFile) -> List<T>): List<T> {
+ return withContext { environment, session ->
+ environment.getSourceFiles().flatMap { file -> processor(session, file) }
}
}
diff --git a/src/Analysis/CommentsAPI.kt b/src/Analysis/CommentsAPI.kt
index a17b6aa4..2407de76 100644
--- a/src/Analysis/CommentsAPI.kt
+++ b/src/Analysis/CommentsAPI.kt
@@ -5,8 +5,8 @@ import org.jetbrains.jet.lang.resolve.*
import org.jetbrains.jet.kdoc.psi.api.*
import org.jetbrains.jet.lang.psi.*
-fun BindingContext.getDocumentationElements(descriptor: DeclarationDescriptor): List<KDoc> {
- val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
+fun DeclarationDescriptor.getDocumentationElements(): List<KDoc> {
+ val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(this)
if (psiElement == null)
return listOf()
diff --git a/src/Analysis/CompilerAPI.kt b/src/Analysis/CompilerAPI.kt
index 43d0304e..8216c549 100644
--- a/src/Analysis/CompilerAPI.kt
+++ b/src/Analysis/CompilerAPI.kt
@@ -46,8 +46,6 @@ fun JetCoreEnvironment.analyze(): ResolveSession {
return resolverForProject.resolverForModule(module).lazyResolveSession
}
-fun BindingContext.getPackageFragment(file: JetFile): PackageFragmentDescriptor? = get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file)
-
fun DeclarationDescriptor.isUserCode() =
when (this) {
is PackageViewDescriptor -> false
@@ -122,7 +120,7 @@ public fun getPropertyInnerScope(outerScope: JetScope, descriptor: PropertyDescr
return propertyScope
}
-fun BindingContext.getResolutionScope(descriptor: DeclarationDescriptor): JetScope {
+fun getResolutionScope(descriptor: DeclarationDescriptor): JetScope {
when (descriptor) {
is PackageFragmentDescriptor ->
return getPackageInnerScope(descriptor)