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)) {
classifier = { ExpectedInfoClassification.MATCHES } /* we do not need to check type of enum entry because it's taken from proper enum */
}
else{
else {
return
}
@@ -96,38 +96,34 @@ fun MutableCollection<LookupElement>.addLookupElements(expectedInfos: Collection
}
fun MutableCollection<LookupElement>.addLookupElementsForNullable(factory: () -> LookupElement?, matchedInfos: Collection<ExpectedInfo>) {
run {
var lookupElement = factory()
if (lookupElement != null) {
lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) {
override fun renderElement(presentation: LookupElementPresentation) {
super.renderElement(presentation)
presentation.setItemText("!! " + presentation.getItemText())
}
override fun handleInsert(context: InsertionContext) {
WithTailStringInsertHandler("!!").handleInsert(context, getDelegate())
}
var lookupElement = factory()
if (lookupElement != null) {
lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) {
override fun renderElement(presentation: LookupElementPresentation) {
super.renderElement(presentation)
presentation.setItemText("!! " + presentation.getItemText())
}
override fun handleInsert(context: InsertionContext) {
WithTailStringInsertHandler("!!").handleInsert(context, getDelegate())
}
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
}
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
}
run {
var lookupElement = factory()
if (lookupElement != null) {
lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) {
override fun renderElement(presentation: LookupElementPresentation) {
super.renderElement(presentation)
presentation.setItemText("?: " + presentation.getItemText())
}
override fun handleInsert(context: InsertionContext) {
WithTailStringInsertHandler(" ?: ").handleInsert(context, getDelegate()) //TODO: code style
}
lookupElement = factory()
if (lookupElement != null) {
lookupElement = object: LookupElementDecorator<LookupElement>(lookupElement!!) {
override fun renderElement(presentation: LookupElementPresentation) {
super.renderElement(presentation)
presentation.setItemText("?: " + presentation.getItemText())
}
override fun handleInsert(context: InsertionContext) {
WithTailStringInsertHandler(" ?: ").handleInsert(context, getDelegate()) //TODO: code style
}
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
}
lookupElement = lookupElement!!.suppressAutoInsertion()
add(lookupElement!!.addTail(matchedInfos))
}
}