KT-56941 Gradle KTS navigation: go to declaration (Java) doesn't work
Case: ``` options.incrementalAfterFailure = false // assignment operator (a) options.incrementalAfterFailure.set(false) // equivalent (without) (b) // (a) works thanks to AssignResolutionAltererExtension // 'incrementalAfterFailure' is a synthetic Java property // i.e. getIncrementalAfterFailure() // Navigation to 'incrementalAfterFailure' (a) doesn't work. ``` By navigation, we mean opening declaration sources. The reason of the issue lied in sources absence (inability to find them). In general, sources are available via declaration descriptor. To find one for a property, one needs to understand expression kind: read/write/both. Hence, the choice of a getter/setter/both. Since `=` operator is interpreted as a write type expression, a setter was searched. Missing one resulted in corrupted navigation. As a fix we provide getter for the missing setter case. ^KT-56941 fixed
This commit is contained in:
committed by
Space Team
parent
e3d5affe5c
commit
66a74ab60e
+6
-2
@@ -51,8 +51,12 @@ internal class KtFirSimpleNameReference(
|
||||
referenceTargetSymbols.flatMap { symbol ->
|
||||
when (symbol) {
|
||||
is KtFirSyntheticJavaPropertySymbol ->
|
||||
if (isRead) listOfNotNull(symbol.javaGetterSymbol.psi)
|
||||
else listOfNotNull(symbol.javaSetterSymbol?.psi)
|
||||
if (isRead) {
|
||||
listOfNotNull(symbol.javaGetterSymbol.psi)
|
||||
} else {
|
||||
if (symbol.javaSetterSymbol == null) listOfNotNull(symbol.javaGetterSymbol.psi)
|
||||
else listOfNotNull(symbol.javaSetterSymbol?.psi)
|
||||
}
|
||||
else -> listOfNotNull(symbol.psi)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -32,7 +32,8 @@ class Fe10SyntheticPropertyAccessorReference(
|
||||
if (getter) {
|
||||
result.add(descriptor.getMethod)
|
||||
} else {
|
||||
result.addIfNotNull(descriptor.setMethod)
|
||||
if (descriptor.setMethod == null) result.addIfNotNull(descriptor.getMethod)
|
||||
else result.addIfNotNull(descriptor.setMethod)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user