aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Analysis/AnalysisEnvironment.kt27
-rw-r--r--src/Analysis/CompilerAPI.kt24
-rw-r--r--src/Formats/FormatService.kt2
-rw-r--r--src/Formats/OutlineService.kt2
-rw-r--r--src/Formats/StructuredFormatService.kt2
-rw-r--r--src/Generation/ConsoleGenerator.kt2
-rw-r--r--src/Kotlin/ContentBuilder.kt28
-rw-r--r--src/Kotlin/DocumentationBuilder.kt22
-rw-r--r--src/Model/Content.kt2
-rw-r--r--src/Model/PackageDocs.kt4
-rw-r--r--src/Model/SourceLinks.kt7
11 files changed, 64 insertions, 58 deletions
diff --git a/src/Analysis/AnalysisEnvironment.kt b/src/Analysis/AnalysisEnvironment.kt
index 39a05604..8fdb0b51 100644
--- a/src/Analysis/AnalysisEnvironment.kt
+++ b/src/Analysis/AnalysisEnvironment.kt
@@ -4,24 +4,25 @@ import com.intellij.core.CoreApplicationEnvironment
import com.intellij.core.CoreModuleManager
import com.intellij.mock.MockComponentManager
import com.intellij.openapi.Disposable
-import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
-import com.intellij.openapi.roots.ContentIterator
-import com.intellij.openapi.roots.OrderEntry
import com.intellij.openapi.roots.ProjectFileIndex
import com.intellij.openapi.util.Disposer
-import com.intellij.openapi.vfs.VirtualFile
-import org.jetbrains.jps.model.module.JpsModuleSourceRootType
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
-import org.jetbrains.kotlin.cli.jvm.config.*
-import org.jetbrains.kotlin.config.*
+import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
+import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
+import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots
+import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
+import org.jetbrains.kotlin.config.CommonConfigurationKeys
+import org.jetbrains.kotlin.config.CompilerConfiguration
+import org.jetbrains.kotlin.config.ContentRoot
+import org.jetbrains.kotlin.config.KotlinSourceRoot
import org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheService
import org.jetbrains.kotlin.idea.caches.resolve.KotlinOutOfBlockCompletionModificationTracker
import org.jetbrains.kotlin.idea.caches.resolve.LibraryModificationTracker
-import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade
+import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
import java.io.File
@@ -51,15 +52,15 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A
val moduleManager = CoreModuleManager(environment.project, this)
CoreApplicationEnvironment.registerComponentInstance(projectComponentManager.getPicoContainer(),
- javaClass<ModuleManager>(), moduleManager)
+ ModuleManager::class.java, moduleManager)
- projectComponentManager.registerService(javaClass<ProjectFileIndex>(),
+ projectComponentManager.registerService(ProjectFileIndex::class.java,
CoreProjectFileIndex())
- projectComponentManager.registerService(javaClass<LibraryModificationTracker>(),
+ projectComponentManager.registerService(LibraryModificationTracker::class.java,
LibraryModificationTracker(environment.project))
- projectComponentManager.registerService(javaClass<KotlinCacheService>(),
+ projectComponentManager.registerService(KotlinCacheService::class.java,
KotlinCacheService(environment.project))
- projectComponentManager.registerService(javaClass<KotlinOutOfBlockCompletionModificationTracker>(),
+ projectComponentManager.registerService(KotlinOutOfBlockCompletionModificationTracker::class.java,
KotlinOutOfBlockCompletionModificationTracker())
val sourceFiles = environment.getSourceFiles()
diff --git a/src/Analysis/CompilerAPI.kt b/src/Analysis/CompilerAPI.kt
index 8b877204..f4382bbb 100644
--- a/src/Analysis/CompilerAPI.kt
+++ b/src/Analysis/CompilerAPI.kt
@@ -1,17 +1,16 @@
package org.jetbrains.dokka
-import org.jetbrains.kotlin.cli.common.arguments.*
-import org.jetbrains.kotlin.cli.jvm.compiler.*
-import org.jetbrains.kotlin.utils.*
-import java.io.*
-import org.jetbrains.kotlin.resolve.jvm.*
-import org.jetbrains.kotlin.analyzer.*
-import org.jetbrains.kotlin.descriptors.*
-import org.jetbrains.kotlin.resolve.scopes.*
-import org.jetbrains.kotlin.context.GlobalContext
import com.intellij.psi.search.GlobalSearchScope
+import org.jetbrains.kotlin.analyzer.ModuleContent
+import org.jetbrains.kotlin.analyzer.ModuleInfo
+import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider
+import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
+import org.jetbrains.kotlin.container.get
import org.jetbrains.kotlin.context.ProjectContext
import org.jetbrains.kotlin.name.Name
+import org.jetbrains.kotlin.resolve.CompilerEnvironment
+import org.jetbrains.kotlin.resolve.jvm.JvmAnalyzerFacade
+import org.jetbrains.kotlin.resolve.jvm.JvmPlatformParameters
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
fun KotlinCoreEnvironment.analyze(): ResolveSession {
@@ -26,7 +25,10 @@ fun KotlinCoreEnvironment.analyze(): ResolveSession {
projectContext,
listOf(module),
{ ModuleContent(sourceFiles, GlobalSearchScope.allScope(project)) },
- JvmPlatformParameters { module }
+ JvmPlatformParameters { module },
+ CompilerEnvironment,
+ packagePartProviderFactory = { module, content -> JvmPackagePartProvider(this) }
)
- return resolverForProject.resolverForModule(module).lazyResolveSession
+
+ return resolverForProject.resolverForModule(module).componentProvider.get<ResolveSession>()
}
diff --git a/src/Formats/FormatService.kt b/src/Formats/FormatService.kt
index 93470a4c..642fad04 100644
--- a/src/Formats/FormatService.kt
+++ b/src/Formats/FormatService.kt
@@ -17,4 +17,4 @@ public interface FormatService {
}
/** Format content to [String] using specified [location] */
-fun FormatService.format(location: Location, nodes: Iterable<DocumentationNode>): String = StringBuilder { appendNodes(location, this, nodes) }.toString()
+fun FormatService.format(location: Location, nodes: Iterable<DocumentationNode>): String = kotlin.StringBuilder { appendNodes(location, this, nodes) }.toString()
diff --git a/src/Formats/OutlineService.kt b/src/Formats/OutlineService.kt
index 6c7e882e..31128d6d 100644
--- a/src/Formats/OutlineService.kt
+++ b/src/Formats/OutlineService.kt
@@ -16,7 +16,7 @@ public interface OutlineFormatService {
for (node in nodes) {
appendOutlineHeader(location, node, to)
if (node.members.any()) {
- val sortedMembers = node.members.sortBy { it.name }
+ val sortedMembers = node.members.sortedBy { it.name }
appendOutlineLevel(to) {
appendOutline(location, to, sortedMembers)
}
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt
index a90c60b1..41db84a3 100644
--- a/src/Formats/StructuredFormatService.kt
+++ b/src/Formats/StructuredFormatService.kt
@@ -225,7 +225,7 @@ public abstract class StructuredFormatService(locationService: LocationService,
if (nodes.any()) {
appendHeader(to, caption, 3)
- val children = nodes.sortBy { it.name }
+ val children = nodes.sortedBy { it.name }
val membersMap = children.groupBy { link(node, it) }
appendTable(to) {
diff --git a/src/Generation/ConsoleGenerator.kt b/src/Generation/ConsoleGenerator.kt
index 2f2daa55..803a16e4 100644
--- a/src/Generation/ConsoleGenerator.kt
+++ b/src/Generation/ConsoleGenerator.kt
@@ -20,7 +20,7 @@ public class ConsoleGenerator(val signatureGenerator: LanguageService, val locat
}
public fun generateMembers(node: DocumentationNode, indent: String = "") {
- val items = node.members.sortBy { it.name }
+ val items = node.members.sortedBy { it.name }
for (child in items)
generate(child, indent + IndentStep)
}
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt
index 273009ab..4d9b0c06 100644
--- a/src/Kotlin/ContentBuilder.kt
+++ b/src/Kotlin/ContentBuilder.kt
@@ -1,14 +1,18 @@
package org.jetbrains.dokka
-import java.util.ArrayDeque
-import org.jetbrains.kotlin.descriptors.*
-import org.jetbrains.kotlin.resolve.*
-import org.jetbrains.kotlin.resolve.scopes.*
-import org.jetbrains.kotlin.name.*
+import org.intellij.markdown.MarkdownElementTypes
+import org.intellij.markdown.MarkdownTokenTypes
+import org.jetbrains.kotlin.descriptors.ClassDescriptor
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.kdoc.getResolutionScope
-import org.intellij.markdown.*
-import org.jetbrains.kotlin.psi.JetDeclarationWithBody
+import org.jetbrains.kotlin.name.FqName
+import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.JetBlockExpression
+import org.jetbrains.kotlin.psi.JetDeclarationWithBody
+import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
+import org.jetbrains.kotlin.resolve.scopes.JetScope
+import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
+import java.util.*
public fun buildContent(tree: MarkdownNode, linkResolver: (String) -> ContentBlock): MutableContent {
val result = MutableContent()
@@ -84,10 +88,6 @@ public fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver
parent.append(block)
}
- MarkdownTokenTypes.HTML_ENTITY -> {
- parent.append(ContentEntity(node.text))
- }
-
MarkdownTokenTypes.TEXT,
MarkdownTokenTypes.COLON,
MarkdownTokenTypes.DOUBLE_QUOTE,
@@ -120,8 +120,8 @@ fun DocumentationBuilder.functionBody(descriptor: DeclarationDescriptor, functio
logger.warn("Missing function name in @sample in ${descriptor.signature()}")
return ContentBlockCode().let() { it.append(ContentText("Missing function name in @sample")); it }
}
- val scope = getResolutionScope(resolutionFacade, descriptor)
- val rootPackage = session.getModuleDescriptor().getPackage(FqName.ROOT)!!
+ val scope = getResolutionScope(resolutionFacade, descriptor).asJetScope()
+ val rootPackage = resolutionFacade.moduleDescriptor.getPackage(FqName.ROOT)
val rootScope = rootPackage.memberScope
val symbol = resolveInScope(functionName, scope) ?: resolveInScope(functionName, rootScope)
if (symbol == null) {
@@ -169,7 +169,7 @@ private fun DocumentationBuilder.resolveInScope(functionName: String, scope: Jet
currentScope = if (partSymbol is ClassDescriptor)
partSymbol.getDefaultType().getMemberScope()
else
- getResolutionScope(resolutionFacade, partSymbol)
+ getResolutionScope(resolutionFacade, partSymbol).asJetScope()
symbol = partSymbol
}
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index eda69841..bf336935 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -8,9 +8,10 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotated
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor
-import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.kdoc.KDocFinder
import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
+import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
+import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection
import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
import org.jetbrains.kotlin.lexer.JetSingleValueToken
@@ -35,8 +36,8 @@ public data class DocumentationOptions(val includeNonPublic: Boolean = false,
val sourceLinks: List<SourceLinkDefinition>)
private fun isSamePackage(descriptor1: DeclarationDescriptor, descriptor2: DeclarationDescriptor): Boolean {
- val package1 = DescriptorUtils.getParentOfType(descriptor1, javaClass<PackageFragmentDescriptor>())
- val package2 = DescriptorUtils.getParentOfType(descriptor2, javaClass<PackageFragmentDescriptor>())
+ val package1 = DescriptorUtils.getParentOfType(descriptor1, PackageFragmentDescriptor::class.java)
+ val package2 = DescriptorUtils.getParentOfType(descriptor2, PackageFragmentDescriptor::class.java)
return package1 != null && package2 != null && package1.fqName == package2.fqName
}
@@ -103,9 +104,10 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade,
deepestDescriptor = deepestDescriptor.getOverriddenDescriptors().first()
}
if (DescriptorUtils.getFqName(deepestDescriptor.getContainingDeclaration()).asString() == "kotlin.Any") {
- val anyClassDescriptors = session.getTopLevelClassDescriptors(FqName.fromSegments(listOf("kotlin", "Any")))
+ val anyClassDescriptors = session.getTopLevelClassDescriptors(FqName.fromSegments(listOf("kotlin", "Any")),
+ NoLookupLocation.UNSORTED)
anyClassDescriptors.forEach {
- val anyMethod = it.getMemberScope(listOf()).getFunctions(descriptor.getName()).single()
+ val anyMethod = it.getMemberScope(listOf()).getFunctions(descriptor.getName(), NoLookupLocation.UNSORTED).single()
val kdoc = KDocFinder.findKDoc(anyMethod)
if (kdoc != null) {
return kdoc
@@ -205,7 +207,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade,
return symbol
}
- fun KDocSection.getTags(): Array<KDocTag> = PsiTreeUtil.getChildrenOfType(this, javaClass<KDocTag>()) ?: arrayOf()
+ fun KDocSection.getTags(): Array<KDocTag> = PsiTreeUtil.getChildrenOfType(this, KDocTag::class.java) ?: arrayOf()
private fun MutableContent.addTagToSeeAlso(descriptor: DeclarationDescriptor, seeTag: KDocTag) {
val subjectName = seeTag.getSubjectName()
@@ -330,11 +332,13 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade,
val annotationNode = it.build()
if (annotationNode != null) {
append(annotationNode,
- if (annotationNode.name == "deprecated") DocumentationReference.Kind.Deprecation else DocumentationReference.Kind.Annotation)
+ if (annotationNode.isDeprecation()) DocumentationReference.Kind.Deprecation else DocumentationReference.Kind.Annotation)
}
}
}
+ fun DocumentationNode.isDeprecation() = name == "Deprecated" || name == "deprecated"
+
fun DocumentationNode.appendSourceLink(sourceElement: SourceElement) {
appendSourceLink(sourceElement.getPsi(), options.sourceLinks)
}
@@ -626,7 +630,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade,
} else {
node.appendType(getType())
}
- if (hasDefaultValue()) {
+ if (declaresDefaultValue()) {
val psi = getSource().getPsi() as? JetParameter
if (psi != null) {
val defaultValueText = psi.getDefaultValue()?.getText()
@@ -685,7 +689,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade,
return null
}
val node = DocumentationNode(annotationClass.getName().asString(), Content.Empty, DocumentationNode.Kind.Annotation)
- val arguments = getAllValueArguments().toList().sortBy { it.first.getIndex() }
+ val arguments = getAllValueArguments().toList().sortedBy { it.first.getIndex() }
arguments.forEach {
val valueNode = it.second.toDocumentationNode()
if (valueNode != null) {
diff --git a/src/Model/Content.kt b/src/Model/Content.kt
index 810d6417..032de268 100644
--- a/src/Model/Content.kt
+++ b/src/Model/Content.kt
@@ -142,7 +142,7 @@ public open class MutableContent() : Content() {
public override val summary: ContentNode get() = children.firstOrNull() ?: ContentEmpty
- public override val description: ContentNode by Delegates.lazy {
+ public override val description: ContentNode by lazy {
val descriptionNodes = children.drop(1)
if (descriptionNodes.isEmpty()) {
ContentEmpty
diff --git a/src/Model/PackageDocs.kt b/src/Model/PackageDocs.kt
index 3b0be547..b5ef2126 100644
--- a/src/Model/PackageDocs.kt
+++ b/src/Model/PackageDocs.kt
@@ -13,8 +13,8 @@ public class PackageDocs(val documentationBuilder: DocumentationBuilder,
public val packageContent: Map<String, Content>
get() = _packageContent
- fun parse(file: String) {
- val file = File(file)
+ fun parse(fileName: String) {
+ val file = File(fileName)
if (file.exists()) {
val text = file.readText()
val tree = parseMarkdown(text)
diff --git a/src/Model/SourceLinks.kt b/src/Model/SourceLinks.kt
index 4530518f..52de586c 100644
--- a/src/Model/SourceLinks.kt
+++ b/src/Model/SourceLinks.kt
@@ -50,8 +50,7 @@ fun PsiElement.lineNumber(): Int? {
}
fun PsiElement.columnNumber(): Int? {
- val doc = PsiDocumentManager.getInstance(project).getDocument(containingFile)
- // IJ uses 0-based line-numbers; external source browsers use 1-based
- val lineNumber = doc?.getLineNumber(textRange.startOffset)?.plus(1) ?: return null
- return startOffset - doc!!.getLineStartOffset(lineNumber)
+ val doc = PsiDocumentManager.getInstance(project).getDocument(containingFile) ?: return null
+ val lineNumber = doc.getLineNumber(textRange.startOffset)
+ return startOffset - doc.getLineStartOffset(lineNumber)
} \ No newline at end of file