From 8664d778ad634b0bd89a63cb794760a658f03630 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 10 Nov 2015 16:28:52 +0300 Subject: [PATCH] Merged 2 files --- ...esentation.kt => DeclarationPresenters.kt} | 32 ++++++++++-- .../idea/presentation/KtFunctionPresenter.kt | 50 ------------------- 2 files changed, 29 insertions(+), 53 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/presentation/{KotlinDefaultNamedDeclarationPresentation.kt => DeclarationPresenters.kt} (68%) delete mode 100644 idea/src/org/jetbrains/kotlin/idea/presentation/KtFunctionPresenter.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/presentation/KotlinDefaultNamedDeclarationPresentation.kt b/idea/src/org/jetbrains/kotlin/idea/presentation/DeclarationPresenters.kt similarity index 68% rename from idea/src/org/jetbrains/kotlin/idea/presentation/KotlinDefaultNamedDeclarationPresentation.kt rename to idea/src/org/jetbrains/kotlin/idea/presentation/DeclarationPresenters.kt index 2f41b8c59a6..3e0f5c48823 100644 --- a/idea/src/org/jetbrains/kotlin/idea/presentation/KotlinDefaultNamedDeclarationPresentation.kt +++ b/idea/src/org/jetbrains/kotlin/idea/presentation/DeclarationPresenters.kt @@ -17,14 +17,13 @@ package org.jetbrains.kotlin.idea.presentation import com.intellij.navigation.ColoredItemPresentation +import com.intellij.navigation.ItemPresentation import com.intellij.navigation.ItemPresentationProvider import com.intellij.openapi.editor.colors.CodeInsightColors import com.intellij.openapi.editor.colors.TextAttributesKey import com.intellij.openapi.util.Iconable import org.jetbrains.kotlin.idea.KotlinIconProvider -import org.jetbrains.kotlin.psi.KtCallableDeclaration -import org.jetbrains.kotlin.psi.KtNamedDeclaration -import org.jetbrains.kotlin.psi.KtPsiUtil +import org.jetbrains.kotlin.psi.* open class KotlinDefaultNamedDeclarationPresentation(private val declaration: KtNamedDeclaration) : ColoredItemPresentation { @@ -58,3 +57,30 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt class KtDefaultDeclarationPresenter : ItemPresentationProvider { override fun getPresentation(item: KtNamedDeclaration) = KotlinDefaultNamedDeclarationPresentation(item) } + +class KtFunctionPresenter : ItemPresentationProvider { + override fun getPresentation(function: KtFunction): ItemPresentation? { + if (function is KtFunctionLiteral) return null + + return object : KotlinDefaultNamedDeclarationPresentation(function) { + override fun getPresentableText(): String { + return buildString { + function.name?.let { append(it) } + + append("(") + append(function.valueParameters.joinToString { it.typeReference?.text ?: "" }) + append(")") + } + } + + override fun getLocationString(): String? { + if (function is KtConstructor<*>) { + val name = function.getContainingClassOrObject().fqName ?: return null + return "(in $name)" + } + + return super.getLocationString() + } + } + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/presentation/KtFunctionPresenter.kt b/idea/src/org/jetbrains/kotlin/idea/presentation/KtFunctionPresenter.kt deleted file mode 100644 index c8e273645d7..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/presentation/KtFunctionPresenter.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.presentation - -import com.intellij.navigation.ItemPresentation -import com.intellij.navigation.ItemPresentationProvider -import org.jetbrains.kotlin.psi.KtConstructor -import org.jetbrains.kotlin.psi.KtFunction -import org.jetbrains.kotlin.psi.KtFunctionLiteral - -class KtFunctionPresenter : ItemPresentationProvider { - override fun getPresentation(function: KtFunction): ItemPresentation? { - if (function is KtFunctionLiteral) return null - - return object : KotlinDefaultNamedDeclarationPresentation(function) { - override fun getPresentableText(): String { - return buildString { - function.name?.let { append(it) } - - append("(") - append(function.valueParameters.joinToString { it.typeReference?.text ?: "" }) - append(")") - } - } - - override fun getLocationString(): String? { - if (function is KtConstructor<*>) { - val name = function.getContainingClassOrObject().fqName ?: return null - return "(in $name)" - } - - return super.getLocationString() - } - } - } -}