aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AnalysesEnvironment.kt (renamed from src/AnalysisEnvironment.kt)40
-rw-r--r--src/CommentsAPI.kt2
-rw-r--r--src/DocumentationModel.kt14
-rw-r--r--src/main.kt9
4 files changed, 43 insertions, 22 deletions
diff --git a/src/AnalysisEnvironment.kt b/src/AnalysesEnvironment.kt
index 13316419..3eae33ca 100644
--- a/src/AnalysisEnvironment.kt
+++ b/src/AnalysesEnvironment.kt
@@ -1,18 +1,18 @@
package com.jetbrains.dokka
-import com.intellij.openapi.Disposable
-import org.jetbrains.jet.config.CompilerConfiguration
-import org.jetbrains.jet.cli.common.messages.MessageCollector
-import org.jetbrains.jet.cli.common.CLIConfigurationKeys
-import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
-import java.io.File
-import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
-import org.jetbrains.jet.config.CommonConfigurationKeys
-import com.intellij.openapi.util.Disposer
-import org.jetbrains.jet.lang.resolve.BindingContext
-import org.jetbrains.jet.lang.psi.JetFile
+import com.intellij.openapi.*
+import org.jetbrains.jet.cli.common.messages.*
+import org.jetbrains.jet.cli.common.*
+import org.jetbrains.jet.cli.jvm.compiler.*
+import java.io.*
+import org.jetbrains.jet.cli.jvm.*
+import org.jetbrains.jet.config.*
+import com.intellij.openapi.util.*
+import org.jetbrains.jet.lang.resolve.*
+import org.jetbrains.jet.lang.psi.*
+import kotlin.platform.*
-public class AnalysisEnvironment(val messageCollector: MessageCollector, body: AnalysisEnvironment.()->Unit = {}) : Disposable {
+public class AnalysesEnvironment(val messageCollector: MessageCollector, body: AnalysesEnvironment.() -> Unit = {}) : Disposable {
val configuration = CompilerConfiguration();
{
@@ -20,28 +20,34 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A
body()
}
- private fun processContext<T>(processor: (JetCoreEnvironment, BindingContext) -> T): T {
+ private fun withContext<T>(processor: (JetCoreEnvironment, BindingContext) -> T): T {
val environment = JetCoreEnvironment.createForProduction(this, configuration)
val result = environment.analyze(messageCollector)
return processor(environment, result)
}
- public fun processContext<T>(processor: (BindingContext) -> T): T {
- return processContext { environment, context -> processor(context) }
+ public fun withContext<T>(processor: (BindingContext) -> T): T {
+ return withContext { environment, context -> processor(context) }
}
public fun streamFiles<T>(processor: (BindingContext, JetFile) -> T): Stream<T> {
- return processContext { environment, context ->
+ return withContext { environment, context ->
environment.getSourceFiles().stream().map { file -> processor(context, file) }
}
}
public fun processFiles<T>(processor: (BindingContext, JetFile) -> T): List<T> {
- return processContext { environment, context ->
+ return withContext { environment, context ->
environment.getSourceFiles().map { file -> processor(context, file) }
}
}
+ public fun processFilesFlat<T>(processor: (BindingContext, JetFile) -> List<T>): List<T> {
+ return withContext { environment, context ->
+ environment.getSourceFiles().flatMap { file -> processor(context, file) }
+ }
+ }
+
public val classpath: List<File>
get() = configuration.get(JVMConfigurationKeys.CLASSPATH_KEY) ?: listOf()
diff --git a/src/CommentsAPI.kt b/src/CommentsAPI.kt
index 4bfb19e6..21ba1067 100644
--- a/src/CommentsAPI.kt
+++ b/src/CommentsAPI.kt
@@ -6,7 +6,7 @@ import org.jetbrains.jet.lang.resolve.*
import org.jetbrains.jet.kdoc.psi.api.*
import org.jetbrains.jet.lang.psi.JetDeclaration
-fun BindingContext.getComments(descriptor: DeclarationDescriptor): KDoc? {
+fun BindingContext.getDocumentation(descriptor: DeclarationDescriptor): KDoc? {
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
if (psiElement == null) throw IllegalArgumentException("$descriptor doesn't have connection to source code, is it synthetic?")
diff --git a/src/DocumentationModel.kt b/src/DocumentationModel.kt
new file mode 100644
index 00000000..6da18d42
--- /dev/null
+++ b/src/DocumentationModel.kt
@@ -0,0 +1,14 @@
+package com.jetbrains.dokka
+
+import com.intellij.psi.PsiFile
+import org.jetbrains.jet.lang.resolve.BindingContext
+
+public class DocumentationModel {
+ fun merge(other: DocumentationModel): DocumentationModel {
+ return DocumentationModel()
+ }
+}
+
+fun BindingContext.createDocumentation(file: PsiFile): DocumentationModel {
+ return DocumentationModel()
+} \ No newline at end of file
diff --git a/src/main.kt b/src/main.kt
index 3083ba90..04415070 100644
--- a/src/main.kt
+++ b/src/main.kt
@@ -13,10 +13,11 @@ public fun main(args: Array<String>) {
val compilerArguments = K2JVMCompilerArguments()
val sources: List<String> = Args.parse(compilerArguments, args) ?: listOf()
- val environment = AnalysisEnvironment(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR) {
+ val environment = AnalysesEnvironment(MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR) {
+/*
addClasspath(PathUtil.getJdkClassesRoots())
addClasspath(PathUtil.getKotlinPathsForCompiler().getRuntimePath())
-
+*/
addSources(sources)
}
@@ -52,9 +53,9 @@ fun BindingContext.analyseFile(file: JetFile) {
println("Package: ${packageFragment}")
for (descriptor in packageFragment.getMemberScope().getAllDescriptors()) {
println("Member: ${descriptor}")
- val doc = getComments(descriptor)
+ val doc = getDocumentation(descriptor)
if (doc != null) {
- println("Comment: ${doc.getText()}")
+ println("Comment:\n${doc.getText()}")
}
println()
}