mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
choose isMethodNameOneOf for the API
The reason - it is less error-prone for clients. The code will likely resolve method ref twice, but the second one shall be fast due to caching (~0.0X% overhead). GitOrigin-RevId: ff7e689884406c0325ef0679767da81f39084b6a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
43f9491a10
commit
e5eaaed240
+1
-1
@@ -213,7 +213,7 @@ class KotlinUFunctionCallExpression(
|
||||
return false
|
||||
}
|
||||
|
||||
override fun methodNameCanBeOneOf(names: Collection<String>): Boolean {
|
||||
fun methodNameCanBeOneOf(names: Collection<String>): Boolean {
|
||||
if (isMethodNameOneOfWithoutConsideringImportAliases(names)) return true
|
||||
val ktFile = sourcePsi.containingKtFile
|
||||
val aliasedNames = collectAliasedNamesForName(ktFile, names)
|
||||
|
||||
+2
-1
@@ -1381,7 +1381,8 @@ interface UastResolveApiFixtureTestBase : UastPluginSelection {
|
||||
"Call should be present in the test"
|
||||
}
|
||||
TestCase.assertTrue(call is KotlinUFunctionCallExpression)
|
||||
TestCase.assertTrue("expected method name to be one of ${names}", call!!.methodNameCanBeOneOf(names))
|
||||
val ktCall = call as KotlinUFunctionCallExpression
|
||||
TestCase.assertTrue("expected method name to be one of ${names}", ktCall.methodNameCanBeOneOf(names))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,9 +116,8 @@ interface UCallExpression : UExpression, UResolvable {
|
||||
/**
|
||||
* Tries to perform optimized name checking for cases when [methodName] requires reference resolution.
|
||||
*
|
||||
* May perform some heavy resolution inside for some languages (e.g., for Kotlin). For a lightweight check (with weaker guaranties), see [methodNameCanBeOneOf].
|
||||
* May perform some heavy resolution inside for some languages (e.g., for Kotlin).
|
||||
*
|
||||
* @see methodNameCanBeOneOf
|
||||
* @see methodName
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@@ -126,22 +125,6 @@ interface UCallExpression : UExpression, UResolvable {
|
||||
return names.contains(methodName ?: return false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to check if the call can be resolved to some method with name from [names].
|
||||
*
|
||||
* It may return false-positive results, so an additional resolution check is needed in the case of [methodNameCanBeOneOf] returns `true`.
|
||||
*
|
||||
* Usually do not perform heavy resolution at the cost of sacrificing accuracy (may return false-positive results). For an accurate version which may perform heavy resolve see [isMethodNameOneOf].
|
||||
*
|
||||
* @param names list of method names we want to check it the call can be resolved to
|
||||
* @return `false` if the call can definitely not be resolved to the method with name from [names]. Returns `true` if the call is resolved to the method with name from [names] or this is a false-positive result.
|
||||
* @see isMethodNameOneOf
|
||||
* @see methodName
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
fun methodNameCanBeOneOf(names: Collection<String>): Boolean {
|
||||
return isMethodNameOneOf(names)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("useless since IDEA 2019.2, because getArgumentForParameter moved to UCallExpression", ReplaceWith("UCallExpression"))
|
||||
|
||||
Reference in New Issue
Block a user