From 0b2e3467bb6ae3d6df935063f0bc9579cd392c98 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Mon, 14 Jul 2014 21:14:42 +0400 Subject: Add documentation --- src/Analysis/AnalysisEnvironment.kt | 50 ++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Analysis/AnalysisEnvironment.kt b/src/Analysis/AnalysisEnvironment.kt index 9fe90628..a6cb6f28 100644 --- a/src/Analysis/AnalysisEnvironment.kt +++ b/src/Analysis/AnalysisEnvironment.kt @@ -36,51 +36,93 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A return processor(environment, exhaust.getModuleDescriptor(), exhaust.getBindingContext()) } + /** + * Executes [processor] when analysis is complete. + * $processor is a function to receive compiler module and context for symbol resolution + */ public fun withContext(processor: (ModuleDescriptor, BindingContext) -> T): T { return withContext { environment, module, context -> processor(module, context) } } + /** + * 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(processor: (BindingContext, JetFile) -> T): Stream { return withContext { environment, module, context -> environment.getSourceFiles().stream().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 and file for processing + */ public fun processFiles(processor: (BindingContext, JetFile) -> T): List { 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(processor: (BindingContext, ModuleDescriptor, JetFile) -> T): List { return withContext { environment, module, context -> environment.getSourceFiles().map { file -> processor(context, module, file) } } } + /** + * 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(processor: (BindingContext, JetFile) -> List): List { return withContext { environment, module, context -> environment.getSourceFiles().flatMap { file -> processor(context, file) } } } + /** + * Classpath for this environment. + */ public val classpath: List get() = configuration.get(JVMConfigurationKeys.CLASSPATH_KEY) ?: listOf() - public fun addClasspath(list: List) { - configuration.addAll(JVMConfigurationKeys.CLASSPATH_KEY, list) + /** + * Adds list of paths to classpath. + * $paths collection of paths to add + */ + public fun addClasspath(paths: List) { + configuration.addAll(JVMConfigurationKeys.CLASSPATH_KEY, paths) } - public fun addClasspath(file: File) { - configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, file) + /** + * Adds path to classpath. + * $path path to add + */ + public fun addClasspath(path: File) { + configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, path) } + /** + * List of source roots for this environment. + */ public val sources: List get() = configuration.get(CommonConfigurationKeys.SOURCE_ROOTS_KEY) ?: listOf() + + /** + * Adds list of paths to source roots. + * $list collection of files to add + */ public fun addSources(list: List) { configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, list) } + /** + * Disposes the environment and frees all associated resources. + */ public override fun dispose() { Disposer.dispose(this) } -- cgit