mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 08:51:02 +07:00
PY-76629: Fix DjangoViewNameCompletionTest.testViewNameCompletionInMethods
There were two underlying problems in Kotlin code:
```
run { DjangoFQNamesProvider.ACCEPTS_VIEW_NAME.isNameMatches(this) } != null
```
returned true regardless of the result of `isNameMatches(this)` call.
As a result, we used to suggest Django view names for *all* functions called
"reverse", "redirect" or "reverse_lazy".
Secondly, in FQNamesProviderExtKt.isNameMatches:
```
return getQualifiedNames().any {
return it.firstComponent == elementQualifiedName.firstComponent &&
it.lastComponent == elementQualifiedName.lastComponent
}
```
always returned the result of comparison with the first qualified name, ignoring the rest
due to non-local return from the inline `any`.
Finally, DjangoUrlViewProvider.isReverseFunction expected a PyFunctionType as the type
of reverse/redirect/reverse_lazy, but since these functions have overloads in .pyi
stubs we started to infer a union type of PyFunctionTypes for them, breaking the reference
provider. In general, it's better to perform a name resolution instead of type inference
to detect a fully qualified name for a reference.
GitOrigin-RevId: 69949b1b0e65f00557536cf16127279a83ea4f9d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
20b2e20d26
commit
d69f93c593
@@ -32,7 +32,6 @@ fun FQNamesProvider.isNameMatches(qualifiedNameOwner: PyQualifiedNameOwner): Boo
|
||||
// Relaxed check: package and name
|
||||
val elementQualifiedName = QualifiedName.fromDottedString(qualifiedName)
|
||||
return getQualifiedNames().any {
|
||||
return it.firstComponent == elementQualifiedName.firstComponent &&
|
||||
it.lastComponent == elementQualifiedName.lastComponent
|
||||
it.firstComponent == elementQualifiedName.firstComponent && it.lastComponent == elementQualifiedName.lastComponent
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user