Highlight callees resolved to kotlin.suspend as a keywords
#KT-22562 In Progress
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
object LambdaWithSuspendModifierCallChecker : CallChecker {
|
||||
private val KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME = FqName("kotlin.suspend")
|
||||
val KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME = FqName("kotlin.suspend")
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val descriptor = resolvedCall.candidateDescriptor
|
||||
|
||||
+4
@@ -29,9 +29,11 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.LambdaWithSuspendModifierCallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
|
||||
internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingContext: BindingContext) :
|
||||
@@ -78,6 +80,8 @@ internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingCon
|
||||
val key = Extensions.getExtensions(HighlighterExtension.EP_NAME).firstNotNullResult { extension ->
|
||||
extension.highlightCall(callee, resolvedCall)
|
||||
} ?: when {
|
||||
calleeDescriptor.fqNameOrNull() ==
|
||||
LambdaWithSuspendModifierCallChecker.KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME -> KEYWORD
|
||||
calleeDescriptor.isDynamic() -> DYNAMIC_FUNCTION_CALL
|
||||
resolvedCall is VariableAsFunctionResolvedCall -> {
|
||||
val container = calleeDescriptor.containingDeclaration
|
||||
|
||||
+7
@@ -1,3 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">global</info>() {
|
||||
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">inner</info>() {
|
||||
|
||||
@@ -20,3 +21,9 @@ fun <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="K
|
||||
5 <info textAttributesKey="KOTLIN_EXTENSION_FUNCTION_CALL">fif</info> 6
|
||||
}
|
||||
}
|
||||
|
||||
fun <info descr="null" textAttributesKey="KOTLIN_FUNCTION_DECLARATION">foo</info>() {
|
||||
<warning descr="[EXPERIMENTAL_FEATURE_WARNING] The feature \"coroutines\" is experimental (see: https://kotlinlang.org/docs/diagnostics/experimental-coroutines)" textAttributesKey="WARNING_ATTRIBUTES"><info descr="null" textAttributesKey="KOTLIN_KEYWORD">suspend</info></warning> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.rt.execution.junit.FileComparisonFailure;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor;
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
||||
import org.jetbrains.kotlin.test.TagsTestDataUtil;
|
||||
|
||||
@@ -31,11 +28,6 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractHighlightingTest extends KotlinLightCodeInsightFixtureTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return KotlinLightProjectDescriptor.INSTANCE;
|
||||
}
|
||||
|
||||
protected void doTest(String filePath) throws Exception {
|
||||
String fileText = FileUtil.loadFile(new File(filePath), true);
|
||||
@@ -57,10 +49,4 @@ public abstract class AbstractHighlightingTest extends KotlinLightCodeInsightFix
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user