Implement test icon provider for 'native' platform

This commit is contained in:
Yan Zhulanow
2019-09-02 18:26:32 +09:00
parent c19d62af73
commit 8f4063b36c
6 changed files with 123 additions and 61 deletions
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ide.konan
interface KotlinNativeRunConfigurationProvider {
val isForTests: Boolean
}
@@ -5,17 +5,18 @@
package org.jetbrains.kotlin.ide.konan
import com.intellij.execution.actions.RunConfigurationProducer
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.libraries.DummyLibraryProperties
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription
import org.jetbrains.kotlin.ide.konan.analyzer.NativeResolverForModuleFactory
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.gradle.KotlinPlatform
import org.jetbrains.kotlin.idea.framework.KotlinLibraryKind
import org.jetbrains.kotlin.idea.platform.IdePlatformKindTooling
import org.jetbrains.kotlin.idea.platform.getGenericTestIcon
import org.jetbrains.kotlin.platform.impl.NativeIdePlatformKind
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtNamedDeclaration
@@ -37,7 +38,21 @@ class NativeIdePlatformKindTooling : IdePlatformKindTooling() {
override fun getLibraryDescription(project: Project): CustomLibraryDescription? = null
override fun getLibraryVersionProvider(project: Project): (Library) -> String? = { null }
override fun getTestIcon(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor): Icon? = null
override fun getTestIcon(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor): Icon? {
return getGenericTestIcon(declaration, descriptor) {
val availableRunConfigurations = RunConfigurationProducer
.getProducers(declaration.project)
.asSequence()
.filterIsInstance<KotlinNativeRunConfigurationProvider>()
.filter { it.isForTests }
if (availableRunConfigurations.firstOrNull() == null) {
return@getGenericTestIcon null
}
return@getGenericTestIcon emptyList()
}
}
override fun acceptsAsEntryPoint(function: KtFunction) = false
}