Renamed classes
This commit is contained in:
@@ -22,7 +22,7 @@ import org.jetbrains.jet.lang.psi.*
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.filters.position.PositionElementFilter
|
||||
import com.intellij.codeInsight.completion.*
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler
|
||||
import org.jetbrains.jet.plugin.completion.handlers.KotlinFunctionInsertHandler
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
||||
import com.intellij.psi.PsiErrorElement
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken
|
||||
@@ -60,7 +60,7 @@ object KeywordCompletion {
|
||||
.withInsertHandler(if (keywordToken !in FUNCTION_KEYWORDS)
|
||||
KotlinKeywordInsertHandler
|
||||
else
|
||||
JetFunctionInsertHandler.NO_PARAMETERS_HANDLER)
|
||||
KotlinFunctionInsertHandler.NO_PARAMETERS_HANDLER)
|
||||
collector.addElement(element)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public object KotlinLookupElementFactory {
|
||||
element = element.withIcon(JetDescriptorIconProvider.getIcon(descriptor, declaration, Iconable.ICON_FLAG_VISIBILITY))
|
||||
element = element.withStrikeoutness(KotlinBuiltIns.getInstance().isDeprecated(descriptor))
|
||||
|
||||
if (insertHandler is JetFunctionInsertHandler && insertHandler.lambdaInfo != null) {
|
||||
if (insertHandler is KotlinFunctionInsertHandler && insertHandler.lambdaInfo != null) {
|
||||
element.putUserData<Boolean>(KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE, true)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public object KotlinLookupElementFactory {
|
||||
is FunctionDescriptor -> {
|
||||
val parameters = descriptor.getValueParameters()
|
||||
when (parameters.size) {
|
||||
0 -> JetFunctionInsertHandler.NO_PARAMETERS_HANDLER
|
||||
0 -> KotlinFunctionInsertHandler.NO_PARAMETERS_HANDLER
|
||||
|
||||
1 -> {
|
||||
val parameterType = parameters.single().getType()
|
||||
@@ -112,17 +112,17 @@ public object KotlinLookupElementFactory {
|
||||
val parameterCount = KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(parameterType).size()
|
||||
if (parameterCount <= 1) {
|
||||
// otherwise additional item with lambda template is to be added
|
||||
return JetFunctionInsertHandler(CaretPosition.IN_BRACKETS, GenerateLambdaInfo(parameterType, false))
|
||||
return KotlinFunctionInsertHandler(CaretPosition.IN_BRACKETS, GenerateLambdaInfo(parameterType, false))
|
||||
}
|
||||
}
|
||||
JetFunctionInsertHandler.WITH_PARAMETERS_HANDLER
|
||||
KotlinFunctionInsertHandler.WITH_PARAMETERS_HANDLER
|
||||
}
|
||||
|
||||
else -> JetFunctionInsertHandler.WITH_PARAMETERS_HANDLER
|
||||
else -> KotlinFunctionInsertHandler.WITH_PARAMETERS_HANDLER
|
||||
}
|
||||
}
|
||||
|
||||
is PropertyDescriptor -> JetPropertyInsertHandler
|
||||
is PropertyDescriptor -> KotlinPropertyInsertHandler
|
||||
|
||||
is ClassDescriptor -> KotlinClassInsertHandler
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class LookupElementsCollector(private val prefixMatcher: PrefixMatcher, private
|
||||
}
|
||||
|
||||
override fun handleInsert(context: InsertionContext) {
|
||||
JetFunctionInsertHandler(CaretPosition.IN_BRACKETS, GenerateLambdaInfo(parameterType, true)).handleInsert(context, this)
|
||||
KotlinFunctionInsertHandler(CaretPosition.IN_BRACKETS, GenerateLambdaInfo(parameterType, true)).handleInsert(context, this)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+5
-5
@@ -39,7 +39,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||
|
||||
public abstract class JetCallableInsertHandler : BaseDeclarationInsertHandler() {
|
||||
public abstract class KotlinCallableInsertHandler : BaseDeclarationInsertHandler() {
|
||||
public override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
||||
super.handleInsert(context, item)
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class JetCallableInsertHandler : BaseDeclarationInsertHandler()
|
||||
}
|
||||
}
|
||||
|
||||
public object JetPropertyInsertHandler : JetCallableInsertHandler()
|
||||
public object KotlinPropertyInsertHandler : KotlinCallableInsertHandler()
|
||||
|
||||
public enum class CaretPosition {
|
||||
IN_BRACKETS
|
||||
@@ -85,7 +85,7 @@ public enum class CaretPosition {
|
||||
|
||||
public data class GenerateLambdaInfo(val lambdaType: JetType, val explicitParameters: Boolean)
|
||||
|
||||
public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val lambdaInfo: GenerateLambdaInfo?) : JetCallableInsertHandler() {
|
||||
public class KotlinFunctionInsertHandler(val caretPosition : CaretPosition, val lambdaInfo: GenerateLambdaInfo?) : KotlinCallableInsertHandler() {
|
||||
{
|
||||
if (caretPosition == CaretPosition.AFTER_BRACKETS && lambdaInfo != null) {
|
||||
throw IllegalArgumentException("CaretPosition.AFTER_BRACKETS with lambdaInfo != null combination is not supported")
|
||||
@@ -190,8 +190,8 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val lam
|
||||
}
|
||||
|
||||
class object {
|
||||
public val NO_PARAMETERS_HANDLER: JetFunctionInsertHandler = JetFunctionInsertHandler(CaretPosition.AFTER_BRACKETS, null)
|
||||
public val WITH_PARAMETERS_HANDLER: JetFunctionInsertHandler = JetFunctionInsertHandler(CaretPosition.IN_BRACKETS, null)
|
||||
public val NO_PARAMETERS_HANDLER: KotlinFunctionInsertHandler = KotlinFunctionInsertHandler(CaretPosition.AFTER_BRACKETS, null)
|
||||
public val WITH_PARAMETERS_HANDLER: KotlinFunctionInsertHandler = KotlinFunctionInsertHandler(CaretPosition.IN_BRACKETS, null)
|
||||
|
||||
private fun shouldAddBrackets(element : PsiElement) : Boolean {
|
||||
return PsiTreeUtil.getParentOfType(element, javaClass<JetImportDirective>()) == null
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.intellij.codeInsight.lookup.LookupElementDecorator
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||
import com.intellij.codeInsight.completion.InsertionContext
|
||||
import org.jetbrains.jet.plugin.project.ResolveSessionForBodies
|
||||
import org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler
|
||||
import org.jetbrains.jet.plugin.completion.handlers.KotlinFunctionInsertHandler
|
||||
import org.jetbrains.jet.plugin.completion.*
|
||||
import org.jetbrains.jet.plugin.completion.handlers.CaretPosition
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
@@ -102,11 +102,11 @@ class TypeInstantiationItems(val resolveSession: ResolveSessionForBodies, val bi
|
||||
itemText += "()"
|
||||
val baseInsertHandler =
|
||||
(if (visibleConstructors.size == 0)
|
||||
JetFunctionInsertHandler.NO_PARAMETERS_HANDLER
|
||||
KotlinFunctionInsertHandler.NO_PARAMETERS_HANDLER
|
||||
else if (visibleConstructors.size == 1)
|
||||
KotlinLookupElementFactory.getDefaultInsertHandler(visibleConstructors.single())
|
||||
else
|
||||
JetFunctionInsertHandler.WITH_PARAMETERS_HANDLER) as JetFunctionInsertHandler
|
||||
KotlinFunctionInsertHandler.WITH_PARAMETERS_HANDLER) as KotlinFunctionInsertHandler
|
||||
insertHandler = object : InsertHandler<LookupElement> {
|
||||
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
||||
context.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), typeText)
|
||||
|
||||
Reference in New Issue
Block a user