Smart completion: minor changes

This commit is contained in:
Valentin Kipyatkov
2014-04-22 14:15:07 +04:00
parent e017f4d952
commit 19aa35ffeb
2 changed files with 23 additions and 27 deletions
@@ -62,7 +62,7 @@ class StaticMembers(val bindingContext: BindingContext, val resolveSession: Reso
else if (DescriptorUtils.isEnumEntry(descriptor)) { else if (DescriptorUtils.isEnumEntry(descriptor)) {
classifier = { ExpectedInfoClassification.MATCHES } /* we do not need to check type of enum entry because it's taken from proper enum */ classifier = { ExpectedInfoClassification.MATCHES } /* we do not need to check type of enum entry because it's taken from proper enum */
} }
else{ else {
return return
} }
@@ -96,38 +96,34 @@ fun MutableCollection<LookupElement>.addLookupElements(expectedInfos: Collection
} }
fun MutableCollection<LookupElement>.addLookupElementsForNullable(factory: () -> LookupElement?, matchedInfos: Collection<ExpectedInfo>) { fun MutableCollection<LookupElement>.addLookupElementsForNullable(factory: () -> LookupElement?, matchedInfos: Collection<ExpectedInfo>) {
run { var lookupElement = factory()
var lookupElement = factory() if (lookupElement != null) {
if (lookupElement != null) { lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) {
lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) { override fun renderElement(presentation: LookupElementPresentation) {
override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation)
super.renderElement(presentation) presentation.setItemText("!! " + presentation.getItemText())
presentation.setItemText("!! " + presentation.getItemText()) }
} override fun handleInsert(context: InsertionContext) {
override fun handleInsert(context: InsertionContext) { WithTailStringInsertHandler("!!").handleInsert(context, getDelegate())
WithTailStringInsertHandler("!!").handleInsert(context, getDelegate())
}
} }
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
} }
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
} }
run { lookupElement = factory()
var lookupElement = factory() if (lookupElement != null) {
if (lookupElement != null) { lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) {
lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) { override fun renderElement(presentation: LookupElementPresentation) {
override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation)
super.renderElement(presentation) presentation.setItemText("?: " + presentation.getItemText())
presentation.setItemText("?: " + presentation.getItemText()) }
} override fun handleInsert(context: InsertionContext) {
override fun handleInsert(context: InsertionContext) { WithTailStringInsertHandler(" ?: ").handleInsert(context, getDelegate()) //TODO: code style
WithTailStringInsertHandler(" ?: ").handleInsert(context, getDelegate()) //TODO: code style
}
} }
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
} }
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
} }
} }