aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/utilities
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-07-05 10:04:55 +0200
committerGitHub <noreply@github.com>2023-07-05 10:04:55 +0200
commit9559158bfeeb274e9ccf1b4563f1b23b42afc493 (patch)
tree3ece0887623cfe2b7148af23001867a1dd5e6597 /core/src/main/kotlin/utilities
parentcbd9733d3dd2f52992e98e7cebd072091a572529 (diff)
downloaddokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.tar.gz
dokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.tar.bz2
dokka-9559158bfeeb274e9ccf1b4563f1b23b42afc493.zip
Decompose Kotlin/Java analysis (#3034)
* Extract analysis into separate modules
Diffstat (limited to 'core/src/main/kotlin/utilities')
-rw-r--r--core/src/main/kotlin/utilities/Collections.kt25
-rw-r--r--core/src/main/kotlin/utilities/Html.kt2
-rw-r--r--core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt2
-rw-r--r--core/src/main/kotlin/utilities/ServiceLocator.kt2
-rw-r--r--core/src/main/kotlin/utilities/Uri.kt2
-rw-r--r--core/src/main/kotlin/utilities/associateWithNotNull.kt2
-rw-r--r--core/src/main/kotlin/utilities/cast.kt2
-rw-r--r--core/src/main/kotlin/utilities/parallelCollectionOperations.kt7
8 files changed, 36 insertions, 8 deletions
diff --git a/core/src/main/kotlin/utilities/Collections.kt b/core/src/main/kotlin/utilities/Collections.kt
new file mode 100644
index 00000000..b18752f7
--- /dev/null
+++ b/core/src/main/kotlin/utilities/Collections.kt
@@ -0,0 +1,25 @@
+package org.jetbrains.dokka.utilities
+
+import org.jetbrains.dokka.InternalDokkaApi
+
+/**
+ * This utility method was previously imported from `org.jetbrains.kotlin.utils.addToStdlib`,
+ * and there were a lot of usages. Since no replacement exists in stdlib, it was implemented
+ * locally for convenience.
+ */
+@InternalDokkaApi
+inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? {
+ for (element in this) if (element is T) return element
+ return null
+}
+
+/**
+ * This utility method was previously imported from `org.jetbrains.kotlin.utils.addToStdlib`,
+ * and there were a lot of usages. Since no replacement exists in stdlib, it was implemented
+ * locally for convenience.
+ */
+@InternalDokkaApi
+inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? {
+ for (element in this) if (element is T) return element
+ return null
+}
diff --git a/core/src/main/kotlin/utilities/Html.kt b/core/src/main/kotlin/utilities/Html.kt
index a1d8ecec..262dd0a0 100644
--- a/core/src/main/kotlin/utilities/Html.kt
+++ b/core/src/main/kotlin/utilities/Html.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.utilities
-import org.jetbrains.dokka.*
+import org.jetbrains.dokka.InternalDokkaApi
import java.net.URLEncoder
diff --git a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt
index c29d1b2a..e1b42388 100644
--- a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt
+++ b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.utilities
-import org.jetbrains.dokka.*
+import org.jetbrains.dokka.InternalDokkaApi
@InternalDokkaApi
interface SelfRepresentingSingletonSet<T : SelfRepresentingSingletonSet<T>> : Set<T> {
diff --git a/core/src/main/kotlin/utilities/ServiceLocator.kt b/core/src/main/kotlin/utilities/ServiceLocator.kt
index f86960ec..b5b19057 100644
--- a/core/src/main/kotlin/utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/utilities/ServiceLocator.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.utilities
-import org.jetbrains.dokka.*
+import org.jetbrains.dokka.InternalDokkaApi
import java.io.File
import java.net.URISyntaxException
import java.net.URL
diff --git a/core/src/main/kotlin/utilities/Uri.kt b/core/src/main/kotlin/utilities/Uri.kt
index 67c81d98..ef8549f7 100644
--- a/core/src/main/kotlin/utilities/Uri.kt
+++ b/core/src/main/kotlin/utilities/Uri.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.utilities
-import org.jetbrains.dokka.*
+import org.jetbrains.dokka.InternalDokkaApi
import java.net.URI
@InternalDokkaApi
diff --git a/core/src/main/kotlin/utilities/associateWithNotNull.kt b/core/src/main/kotlin/utilities/associateWithNotNull.kt
index 6c0bf4d8..9ff55d2c 100644
--- a/core/src/main/kotlin/utilities/associateWithNotNull.kt
+++ b/core/src/main/kotlin/utilities/associateWithNotNull.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.utilities
-import org.jetbrains.dokka.*
+import org.jetbrains.dokka.InternalDokkaApi
@InternalDokkaApi
inline fun <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> {
diff --git a/core/src/main/kotlin/utilities/cast.kt b/core/src/main/kotlin/utilities/cast.kt
index 784b7e2a..9fe76ef6 100644
--- a/core/src/main/kotlin/utilities/cast.kt
+++ b/core/src/main/kotlin/utilities/cast.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.utilities
-import org.jetbrains.dokka.*
+import org.jetbrains.dokka.InternalDokkaApi
@InternalDokkaApi
inline fun <reified T> Any.cast(): T {
diff --git a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt
index d24aa7a6..cff8d735 100644
--- a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt
+++ b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt
@@ -1,7 +1,10 @@
package org.jetbrains.dokka.utilities
-import kotlinx.coroutines.*
-import org.jetbrains.dokka.*
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.launch
+import org.jetbrains.dokka.InternalDokkaApi
@InternalDokkaApi
suspend inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> = coroutineScope {