Partial body resolve: processing of standard "error" function
This commit is contained in:
@@ -278,6 +278,14 @@ class PartialBodyResolveFilter(elementToResolve: JetElement, private val body: J
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitCallExpression(expression: JetCallExpression) {
|
||||
val name = (expression.getCalleeExpression() as? JetSimpleNameExpression)?.getReferencedName()
|
||||
if (name != null && name in possiblyNothingFunctionNames) {
|
||||
result.add(expression)
|
||||
}
|
||||
super.visitCallExpression(expression)
|
||||
}
|
||||
|
||||
override fun visitBinaryExpression(expression: JetBinaryExpression) {
|
||||
if (expression.getOperationToken() == JetTokens.ELVIS) {
|
||||
// do not search exits after "?:"
|
||||
@@ -360,5 +368,9 @@ class PartialBodyResolveFilter(elementToResolve: JetElement, private val body: J
|
||||
|
||||
private fun JetBlockExpression.lastStatement(): JetExpression?
|
||||
= getLastChild().siblings(forward = false).filterIsInstance<JetExpression>().firstOrNull()
|
||||
|
||||
class object {
|
||||
private val possiblyNothingFunctionNames = setOf("error") // currently hard-coded
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Resolve target: val kotlin.String.size: kotlin.Int
|
||||
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String
|
||||
Skipped statements:
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String
|
||||
Skipped statements:
|
||||
@@ -0,0 +1,6 @@
|
||||
fun foo(p: Any) {
|
||||
if (p !is String) {
|
||||
kotlin.error("Not String")
|
||||
}
|
||||
println(<caret>p.size)
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.completion;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
||||
@@ -95,6 +95,18 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("IfNotIsError.kt")
|
||||
public void testIfNotIsError() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNotIsError.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("IfNotIsErrorQualifier.kt")
|
||||
public void testIfNotIsErrorQualifier() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNotIsErrorQualifier.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("IfNotIsReturn.kt")
|
||||
public void testIfNotIsReturn() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNotIsReturn.kt");
|
||||
|
||||
Reference in New Issue
Block a user