How to use buildScopes method of org.spekframework.intellij.domain.ScopeDescriptorCache class

Best Spek code snippet using org.spekframework.intellij.domain.ScopeDescriptorCache.buildScopes

ScopeDescriptorCache.kt

Source:ScopeDescriptorCache.kt Github

copy

Full Screen

...55 .filterIsInstance<KtLambdaExpression>()56 .firstOrNull()57 if (lambda != null) {58 lambda.bodyExpression?.let { body ->59 children.addAll(buildScopes(path, body))60 }61 }62 }63 return ScopeDescriptor.Group(path, clz, false, true, children.toList()).apply {64 index[path.serialize()] = this65 }66 }67 private fun buildScopes(parent: Path, block: KtBlockExpression): List<ScopeDescriptor> {68 val callExpressions = PsiTreeUtil.getChildrenOfTypeAsList(block, KtCallExpression::class.java)69 return callExpressions.mapNotNull { callExpression ->70 val synonymContext = fetchSynonymContext(callExpression)71 when {72 synonymContext != null -> callExpression to synonymContext73 else -> null74 }75 }.mapNotNull { (callExpression, synonymContext) ->76 try {77 val description = synonymContext.constructDescription(callExpression)78 val path = PathBuilder(parent)79 .append(description)80 .build()81 val descriptor = when (synonymContext.synonym.type) {82 PsiSynonymType.GROUP -> {83 val lambdaArgument = callExpression.lambdaArguments.firstOrNull()84 val children = mutableListOf<ScopeDescriptor>()85 if (lambdaArgument != null) {86 val lambdaExpression = lambdaArgument.getLambdaExpression()87 if (lambdaExpression != null) {88 lambdaExpression.bodyExpression?.let { body ->89 children.addAll(buildScopes(path, body))90 }91 }92 }93 ScopeDescriptor.Group(94 path, callExpression, synonymContext.isExcluded(),95 synonymContext.isRunnable(), children.toList()96 )97 }98 PsiSynonymType.TEST -> ScopeDescriptor.Test(99 path, callExpression, synonymContext.isExcluded(), synonymContext.isRunnable()100 )101 }102 index[path.serialize()] = descriptor103 descriptor...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Spek automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful