From bbea70a00513fd3ba6ed4a6ce572befb8f846aa9 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 3 Nov 2015 11:45:31 +0300 Subject: [PATCH] Minor changes on code review --- .../kotlin/idea/completion/BasicCompletionSession.kt | 4 +--- .../jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index 607d7e1edeb..b2b6b6e1686 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -171,14 +171,12 @@ class BasicCompletionSession( val contextVariableTypesForSmartCompletion = withCollectRequiredContextVariableTypes(::completeWithSmartCompletion) - fun completeReferenceVariants(lookupElementFactory: LookupElementFactory) { + val contextVariableTypesForReferenceVariants = withCollectRequiredContextVariableTypes { lookupElementFactory -> val (imported, notImported) = referenceVariantsWithNonInitializedVarExcluded!! collector.addDescriptorElements(imported, lookupElementFactory) collector.addDescriptorElements(notImported, lookupElementFactory, notImported = true) } - val contextVariableTypesForReferenceVariants = withCollectRequiredContextVariableTypes(::completeReferenceVariants) - KEYWORDS_ONLY.doComplete() // getting root packages from scope is very slow so we do this in alternative way diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt index 3cb1950fdb9..62ad697f1fd 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/handlerUtils.kt @@ -29,9 +29,10 @@ fun surroundWithBracesIfInStringTemplate(context: InsertionContext) { if (startOffset > 0 && document.charsSequence[startOffset - 1] == '$') { val psiDocumentManager = PsiDocumentManager.getInstance(context.project) psiDocumentManager.commitAllDocuments() - psiDocumentManager.doPostponedOperationsAndUnblockDocument(document) if (context.file.findElementAt(startOffset - 1)?.node?.elementType == KtTokens.SHORT_TEMPLATE_ENTRY_START) { + psiDocumentManager.doPostponedOperationsAndUnblockDocument(document) + document.insertString(startOffset, "{") context.offsetMap.addOffset(CompletionInitializationContext.START_OFFSET, startOffset + 1)