Best Spek code snippet using org.spekframework.intellij.domain.ScopeDescriptorCache.fromCallExpression
ScopeDescriptorCache.kt
Source:ScopeDescriptorCache.kt
...16 private val index = ConcurrentHashMap<String, ScopeDescriptor?>()17 fun findDescriptor(path: Path): ScopeDescriptor? {18 return index.getOrDefault(path.serialize(), null)19 }20 fun fromCallExpression(callExpression: KtCallExpression): ScopeDescriptor? {21 val context = fetchSynonymContext(callExpression)22 if (context != null) {23 return PsiTreeUtil.getParentOfType(callExpression, KtClassOrObject::class.java)?.let {24 fromClassOrObject(it)?.findDescriptorForElement(callExpression)25 }26 }27 return null28 }29 fun fromClassOrObject(clz: KtClassOrObject): ScopeDescriptor.Group? {30 if (clz.isAbstract() || clz.isObjectLiteral() || !isSpekSubclass(clz)) {31 return null32 }33 val fqName = checkNotNull(clz.fqName).asString()34 var cached = cache.getOrDefault(fqName, null)...
SpekRunConfigurationProducer.kt
Source:SpekRunConfigurationProducer.kt
...36 } else {37 val elementContext = maybeGetContext(it)38 val descriptor = when (elementContext) {39 is KtClassOrObject -> descriptorCache.fromClassOrObject(elementContext)40 is KtCallExpression -> descriptorCache.fromCallExpression(elementContext)41 else -> null42 }43 if (descriptor != null && !descriptor.excluded && descriptor.runnable) {44 descriptor.path45 } else {46 null47 }48 }49 configuration.data.path == path50 } ?: false51 }52 override fun setupConfigurationFromContext(configuration: SpekRunConfiguration<*>,53 context: ConfigurationContext,54 sourceElement: Ref<PsiElement>): Boolean {55 val descriptorCache = checkNotNull(56 context.project.getComponent(ScopeDescriptorCache::class.java)57 )58 return sourceElement.get().let {59 val path = if (it is PsiDirectory) {60 getPackagePath(context, it)61 } else {62 val elementContext = maybeGetContext(it)63 val descriptor = when (elementContext) {64 is KtClassOrObject -> descriptorCache.fromClassOrObject(elementContext)65 is KtCallExpression -> descriptorCache.fromCallExpression(elementContext)66 else -> null67 }68 if (descriptor != null && !descriptor.excluded && descriptor.runnable) {69 descriptor.path70 } else {71 null72 }73 }74 if (path != null) {75 configuration.data.path = path76 val kotlinFacetSettings = KotlinFacetSettingsProvider.getInstance(context.project)77 .getInitializedSettings(context.module)78 var canRun = false79 if (isPlatformSupported(kotlinFacetSettings.platform!!.kind)) {...
SpekRunLineMarkerContributor.kt
Source:SpekRunLineMarkerContributor.kt
...28 is KtClassOrObject -> descriptorCache.fromClassOrObject(parent)29 is KtNameReferenceExpression -> {30 val nameRefParent = parent.parent31 if (nameRefParent is KtCallExpression) {32 descriptorCache.fromCallExpression(nameRefParent)33 } else {34 null35 }36 }37 else -> null38 }39 return descriptor?.let {40 if (!it.excluded && it.runnable) {41 val path = it.path42 Info(43 AllIcons.RunConfigurations.TestState.Run,44 Function<PsiElement, String> { "[Spek] Run ${path.name}"},45 *ExecutorAction.getActions(0)46 )...
fromCallExpression
Using AI Code Generation
1@Suppress("UNCHECKED_CAST")2private val scopeDescriptorCache = ScopeDescriptorCache::class.java.getDeclaredField("INSTANCE").apply {3}.get(null) as ScopeDescriptorCache4val scopeDescriptor = scopeDescriptorCache.fromCallExpression(callExpression)5@Suppress("UNCHECKED_CAST")6private val scopeDescriptorCache = ScopeDescriptorCache::class.java.getDeclaredField("INSTANCE").apply {7}.get(null) as ScopeDescriptorCache8val scopeDescriptor = scopeDescriptorCache.fromCallExpression(callExpression)9class MyTests : Spek({10test("a") {11}12test("b") {13}14})
fromCallExpression
Using AI Code Generation
1val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)2val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)3val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)4val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)5val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)6val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)7val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)8val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)9val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)10val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)11val scopeDescriptor = ScopeDescriptorCache.fromCallExpression(expression)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!