No synthetic properties with incorrect names
This commit is contained in:
+7
-3
@@ -52,6 +52,10 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? {
|
private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? {
|
||||||
|
if (name.isSpecial()) return null
|
||||||
|
val firstChar = name.getIdentifier()[0]
|
||||||
|
if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null
|
||||||
|
|
||||||
val memberScope = javaClass.getMemberScope(type.getArguments())
|
val memberScope = javaClass.getMemberScope(type.getArguments())
|
||||||
val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { isGoodGetMethod(it) } ?: return null
|
val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { isGoodGetMethod(it) } ?: return null
|
||||||
|
|
||||||
@@ -75,8 +79,6 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection<VariableDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection<VariableDescriptor> {
|
||||||
if (name.isSpecial()) return emptyList()
|
|
||||||
if (name.getIdentifier()[0].isUpperCase()) return emptyList()
|
|
||||||
return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList()
|
return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +140,9 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet
|
|||||||
if (methodName.isSpecial()) return null
|
if (methodName.isSpecial()) return null
|
||||||
val identifier = methodName.getIdentifier()
|
val identifier = methodName.getIdentifier()
|
||||||
if (!identifier.startsWith("get")) return null
|
if (!identifier.startsWith("get")) return null
|
||||||
return Name.identifier(identifier.removePrefix("get").decapitalize())
|
val name = identifier.removePrefix("get").decapitalize()
|
||||||
|
if (!Name.isValidIdentifier(name)) return null
|
||||||
|
return Name.identifier(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyPropertyDescriptor(
|
private class MyPropertyDescriptor(
|
||||||
|
|||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
class JavaClass {
|
||||||
|
public int get() { return 1; }
|
||||||
|
public int get1() { return 1; }
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo(javaClass: JavaClass) {
|
||||||
|
javaClass.<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ABSENT: ""
|
||||||
|
// ABSENT: "1"
|
||||||
+6
@@ -131,6 +131,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("IncorrectGetters")
|
||||||
|
public void testIncorrectGetters() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/IncorrectGetters/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JavaInnerClasses")
|
@TestMetadata("JavaInnerClasses")
|
||||||
public void testJavaInnerClasses() throws Exception {
|
public void testJavaInnerClasses() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/JavaInnerClasses/");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/JavaInnerClasses/");
|
||||||
|
|||||||
Reference in New Issue
Block a user