Completion: minor code corrections after review
This commit is contained in:
@@ -98,6 +98,7 @@ public class KotlinIndicesHelper(private val project: Project) {
|
|||||||
private fun MutableCollection<in FunctionDescriptor>.addSourceTopLevelFunctions(name: String, resolveSession: ResolveSessionForBodies, scope: GlobalSearchScope) {
|
private fun MutableCollection<in FunctionDescriptor>.addSourceTopLevelFunctions(name: String, resolveSession: ResolveSessionForBodies, scope: GlobalSearchScope) {
|
||||||
val identifier = Name.identifier(name)
|
val identifier = Name.identifier(name)
|
||||||
val affectedPackages = JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().get(name, project, scope)
|
val affectedPackages = JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().get(name, project, scope)
|
||||||
|
.stream()
|
||||||
.map { it.getContainingFile() }
|
.map { it.getContainingFile() }
|
||||||
.filterIsInstance(javaClass<JetFile>())
|
.filterIsInstance(javaClass<JetFile>())
|
||||||
.map { it.getPackageFqName() }
|
.map { it.getPackageFqName() }
|
||||||
@@ -113,6 +114,7 @@ public class KotlinIndicesHelper(private val project: Project) {
|
|||||||
private fun MutableCollection<in PropertyDescriptor>.addSourceTopLevelProperties(name: String, resolveSession: ResolveSessionForBodies, scope: GlobalSearchScope) {
|
private fun MutableCollection<in PropertyDescriptor>.addSourceTopLevelProperties(name: String, resolveSession: ResolveSessionForBodies, scope: GlobalSearchScope) {
|
||||||
val identifier = Name.identifier(name)
|
val identifier = Name.identifier(name)
|
||||||
val affectedPackages = JetTopLevelNonExtensionPropertyShortNameIndex.getInstance().get(name, project, scope)
|
val affectedPackages = JetTopLevelNonExtensionPropertyShortNameIndex.getInstance().get(name, project, scope)
|
||||||
|
.stream()
|
||||||
.map { it.getContainingFile() }
|
.map { it.getContainingFile() }
|
||||||
.filterIsInstance(javaClass<JetFile>())
|
.filterIsInstance(javaClass<JetFile>())
|
||||||
.map { it.getPackageFqName() }
|
.map { it.getPackageFqName() }
|
||||||
|
|||||||
@@ -165,8 +165,8 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
|
|
||||||
private fun addKotlinTopLevelDeclarations() {
|
private fun addKotlinTopLevelDeclarations() {
|
||||||
val filter = { (name: String) -> prefixMatcher.prefixMatches(name) }
|
val filter = { (name: String) -> prefixMatcher.prefixMatches(name) }
|
||||||
collector.addDescriptorElements(indicesHelper.getTopLevelCallables(filter, jetReference!!.expression, resolveSession, searchScope) +
|
collector.addDescriptorElements(indicesHelper.getTopLevelCallables(filter, jetReference!!.expression, resolveSession, searchScope))
|
||||||
indicesHelper.getTopLevelObjects(filter, resolveSession, searchScope))
|
collector.addDescriptorElements(indicesHelper.getTopLevelObjects(filter, resolveSession, searchScope))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addKotlinExtensions() {
|
private fun addKotlinExtensions() {
|
||||||
|
|||||||
+3
-1
@@ -30,7 +30,9 @@ open class BaseDeclarationInsertHandler : InsertHandler<LookupElement> {
|
|||||||
val name = descriptor.getName()
|
val name = descriptor.getName()
|
||||||
val nameInCode = DescriptorRenderer.SOURCE_CODE.renderName(name)
|
val nameInCode = DescriptorRenderer.SOURCE_CODE.renderName(name)
|
||||||
val document = context.getDocument()
|
val document = context.getDocument()
|
||||||
if (nameInCode != name.asString() && document.getText(TextRange(context.getStartOffset(), context.getTailOffset())) == name.asString()) {
|
val needEscaping = nameInCode != name.asString()
|
||||||
|
// we check that text inserted matches the name because something else can be inserted by custom insert handler
|
||||||
|
if (needEscaping && document.getText(TextRange(context.getStartOffset(), context.getTailOffset())) == name.asString()) {
|
||||||
document.replaceString(context.getStartOffset(), context.getTailOffset(), nameInCode)
|
document.replaceString(context.getStartOffset(), context.getTailOffset(), nameInCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user